991104_src.html | WebReference

991104_src.html

Practicing Safe Code:

CODE SRC Appendix

Code examples from the article Practicing Safe Code:

NOSCRIPT (appears and fills the page if scripting is not enabled.)

<noscript><h1>If you have scripting turned off, you can't play!</h1> <h2><a href="../puzzles/shared/puzzler.html&guot;>Click here for help</a></h2> <h2><a href="../default.htm">Click here to get out.</a></h2>> <p><img src="100x1k.gif" width="100" height="1000"></p> </noscript>

NO STYLE (appears if the browser can't render the style="display:none")

<div style="position:absolute;display:none" > <h1>If you have scripting turned off, you can't play!</h1> <h2><a href="../puzzles/shared/puzzler.html">Click here for help</a></h2> <h2><a href="../default.htm"<Click here to get out.</a></h2> <p><img src="100x1k.gif" </p width="100" height="1000"> </div> BROWSER DETECTION:(routes IE4 or NS4 to separate pages, leaves others on this page) if (parseInt(navigator.appVersion)> 4 || (navigator.appName.indexOf("Netscape") != -1)) window.location.replace( "about.html"); else if(parseInt(navigator.appVersion)>= 4 && (navigator.appName.indexOf("Microsoft") != -1)) indow.location.replace( "webshop.html"); CONDITIONAL LINKS: (This one also tests for a specific javascript version by setting the scr variable to "true" only if it is present.) <script language="JavaScript1.2" type="text/javascript"> var scr="true"; </script> <script language="JavaScript" type="text/javascript"> <!-- var scr=scr function goThere(n){ if (scr != "true")location="shared/puzzler.html"; if (scr == "true"){ document.links[n].href="shared/puzzle9.htm?beast"; return true; } } </script> In the body, this is the html for the previous link redirector: <a href="shared/puzzler.html" onclick="javascript:goThere(0); return true">Click here to go Someplace </a>


Written by Kenneth Tibbetts
All Rights Reserved. Legal Notices.
Created: October 28, 1999
Revised: November 4, 1999

URL: http://www.webreference.com/new/991104_src.html