open...htm
Comments

By clicking on link : "Comments" opens a Pop Up ; the code for this Pop Up is all included into open...htm
From this Pop Up we will replace the Main window with : "replaced.htm" and close at the same time "Comments" The error we want to correct here is to avoid an error interruption if the main window ( this ) has been closed whilst "Comments" is open and the visitor clicks on link "Italian" which refers to execute a function that is set on a disappeared window ...causing an error
...so if this error occurs we handle it with the nested script that we will call ...Error Manager :

<Script language=JavaScript>function go_ahead(){alert("The main w...\\nIt will...");window.open("open...htm","");self.close();return true}; window.onerror=go_ahead;</Script>
(...if the error occurs the code window.onerror switches in recalling the go_ahead function)

Note : The red escape mark and the fact that in the nested script there are no standard html comment to hide the script to old browsers. In the nested script the JavaScript comments can be normally used by caring to set ";" on each end of instruction.
It is reccomanded to use Error Manager with care as in case of other accidental errors becomes diffucult to track the errors ; so please set this script only for interactive operation error occurrency, and test carefully if the correction to this error applies !

listings @ ScriptSearch.com [ ...rate ]
Nested JavaScripts




 
Nested JavaScripts



We don't have to worry on html comments for old browsers'hiding as at this point of the nested script , the interpreter would not arrive , due to the comments present in the Main Script.
For the single quote mark "'" and for slashes "/"we need some extra care so please observe the layout on the right cell.
For other escape charachters we have to test them in a simple script instruction , before using them into larger code lines.
<script Language="Javascript">
<!--
document.write("<br>"+"
<script>var VAR=\"123\";document.write(\"<br>Script in a Script : VAR = \"+VAR+\" ... alert();<br>\"); alert('The single quote mark must be preceeded by a double slash \\\\\\\\ \\n( To write a double slash in this alert() we need 8 of them : \"\\\\\\\\\" \\nand the same applies for the new line instruction !) '); </script>");
//-->
</script>

. . . rate this script  @
 
Top