Writing Friendly Code 12. Finishing Up
home / web / dev / friendly |
Writing Friendly Code 12.
Finishing Up
This is Navigator's new window for outside src files. IE uses the iframe instead.
function nwWind(hrf){
if(brid=="NS" && hrf==1){
newwin=window.open("ywshoe.htm","nsw","resizable,width=580,height=360,scrollbars")
}
if(brid=="NS" && hrf==2){
newwin=window.open("ywforum.htm","nsw","resizable,width=580,height=360,scrollbars")
}
newwin.focus();
}
Messages and infoTips
These are just strings of HTML for IE or NS to use in the popup tips. More can be added at any time from a new document. The infodun and infodun1 strings put a couple buttons on the tips that include them. I'm just including a few samples here; the script has several others. It may be interesting to note that you can write anything to your document in either browser, including buttons that have handlers on the parent.
var infodun1="<p><form><input type='button' class='btn'
name= 'infobtn' value='Close' onclick='turnPage(pg)' > ";
infodun=infodun1+"<input type='button' class='btn' name= 'whomebtn'
value='About' onclick='inform(0)'>";
infodun+="</form></p>";
infodun1+="</form></p>";
var infoCats="<h4><img src='reachcats.gif' height='145'
>" ;
infoCats+="The Yankee Webshop Reader®<br />created by
Areoka and the Carpenter's Cat<br />";
infoCats+="at the Yankee Webshop <br />November,1999 all rights
reserved </h4>";
And now we really are at the end. But remember - this is the place in the script I actually put the event handlers:
if(brid=="NS")window.captureEvents(Event.RESIZE || Event.LOAD ||
Event.UNLOAD);
window.onresize=sizMan;
window.onunload=reStat;
window.onload=isReddy;
Whew.
Here we are, with a Web page to view and interact with. One step at a time, the script handles the events. We are using objects that were derived from the HTML, using and changing the default properties from our stylesheet.
But remember where we are going with all of this - none of this made the Web page possible. The Web page could work without the script at all, or with any number of different scripts we could write for it. That is the key to writing friendly code, friendly and easy to change or maintain. In the script we just examined, for instance, how hard would it be to search and replace all the "brid"s to make a vendor specific change, or to add the specs for some other client?
I have not given a lot of detail about events and Events so far - just enough to get by. They are the center of any interactive Internet code, of course, which is why the next part of this article is all about positioning elements and events. They'll get theirs...
In the meantime, you might like to look at the JavaScript code, the stylesheet the newsletters share, or the HTML template page.
Kenneth Tibbetts ([email protected])
December, 1999
Comments are welcome
Created: Dec. 2, 1999
Revised: Dec. 7, 1999
URL: https://webreference.com/dev/friendly/