spacer

Practicing Safe Code:

Developer News
Microsoft Shows Off Silverlight 4, IE9 Plans
Metasploit Expands Vulnerability Test Framework
HyperCard Reborn?

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>

 

internet.commediabistro.comJusttechjobs.comGraphics.com

Search:

WebMediaBrands Corporate Info

Legal Notices, Licensing, Permissions, Privacy Policy.
Advertise | Newsletters | Shopping | E-mail Offers | Freelance Jobs

webref The latest from WebReference.com Browse >
Rolling Out Your Own HTML Application Version Control · HTML 5: Client-side Storage · Working with Ajax Server Extensions
Sitemap · Experts · Tools · Services · Email a Colleague · Contact FREE Newsletters 
 The latest from internet.com
Wi-Fi Product Watch, November 2009 · Chip Market Recovering From '08 Collapse · Low-Cost Tools to Kickstart Your New Business


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