|
Since some browsers can't read JavaScript, they just read over the JavaScript code as text and show it to the user as text. This fragment of code begins the commenting out of this text if their browser cannot read JavaScript.
/**********************************************************************These are a bunch of comments which must be left in here if you use this script. The /*,anything after it and before */ are comments. When the computer gets to this part, it skips over it.
if(confirm("Your Message And Code To JavaScript Enabled Browsers Goes Here.")) parent.location = "page_control2.html";When the computer spots this command, it first tries to find out if the statement in parentheses is true. Please do not get confused when you see two parenteses at the beginning and two at the end. The first open parentheses are for the if statement while the second are for the confirm function (All functions contain "()" at the end) and the next parenthesis is to end the confirm function while the last is to end the if statement. A good question you may have is how does the computer determine the truth value of this statement (true or false). The answer is that the computer activates this function to find out. The function returns true if the visitor clicks Yes or OK and false if the visitor clicks No or Cancel. If the function returns true, it goes on to the rest of the statement which tells it to do the command parent.location = "page_control2.html". Parent.location means the location of the page that your browser window should contain. Page_control2.html is the value of parent.location so you are taken to page_control2.html. The computer then skips over the else statement because the else statement is used to tell the computer what it should do if the if statement is not true. If the Confirm returns false, it skips over the second half of the if statement because the function returned false and goes to the else statement.
else parent.location = "page_control3.html";As I stated before, if the if statement was false it would go to the else command. This takes your visitor to page_control3.html which is a basic, non-JavaScript copy of this tutorial.
// -- End hiding here -->This ends the commenting out for browsers unable to read JavaScript.
</script>This command tells the computer that the end of the JavaScript source has been reached. If you do not include this in your document source, the rest of your HTML document will be considered as JavaScript and the computer will not be able to comprehend the rest of the document. If you did leave this command out, there will be many JavaScript Error Alerts even if you do not have any commands after it because leaving out </script> messes up the code and any HTML commands after it are considered JavaScript.
<noscript>This command begins the code that should be seen by browsers that are not JavaScript Enabled.
Your Message And Code To Non-JavaScript Enabled Browsers Goes Here.The commands that go here will be read only by browsers that can't read JavaScript (JavaScript illiterate browsers - not people - I know stupid joke). I used text here and provided a link to the non-JavaScript Enabled tutorial on JavaScript Page Controls which is a basic copy of this tutorial.
</noscript>This command ends the code that should be seen by browsers that can't read JavaScript.