Reputation: 3
I am learning Javascript.
I want to:
I am able to read the input and create the string but I cannot get it to launch the website. The string looks correct, however, I am not sure if the problem is actually the string or that I am not launching it correctly. I am able to find examples of each step, but cannot seem to put them together.
Here is my current code: (can't test the link because I cannot see it).
I am sorry if this doesn't come out correctly. It look correct when I paste it.
<script type="text/javascript" >
function myLink() {
var numberEntered = document.getElementById("lessNum").value; //Read input
var lessonlink = 'http://www.ASmarterWayToLearn.com/js/' + numberEntered + '.html'; //Create link
window.open(lessonLink); //Go to link
document.getElementById("theLink").value = lessonLink; // check link address
}
</script>
<!-- Read Lesson number -->
<form>
Lesson Number:<br>
<input type="text" id="lessNum" onBlur="myLink();"><p>
<!-- Display link for verification -->
Link:<br>
<input type="text" id="theLink" style="width: 400px;"><p>
</form>
<p>
Upvotes: 0
Views: 523
Reputation: 2756
In Javascipt :
window.open(yourString);
Source : http://www.w3schools.com/jsref/met_win_open.asp
Upvotes: 1