Contents
Getting started What are CSS? Some CSS tricks CSS cautions What is JavaScript? Some JavaScript tricks JavaScript cautions |
Here are three JavaScript functions you can use to enhance your presentation of your webpages. If you use them, and they don't work for you, drop me a line with the exact code you're using and I'll fix it. No other JavaScript will be dealt with, so don't even try sending me any other scripts.
Well, enough with the blather, right? Not quite. I would like to caution you of something. The alert function I describe below can confuse a blind visitor very much, so use it sparingly, or provide ample warning that such a function is going to be used. I know it looks cool and all, but be mindful of your fellow human beings :) |
<SCRIPT LANGUAGE="JavaScript" TYPE=""> <!-- function ok_box() { alert('Hey, look at ME! \nI\'m an alert box!\nI\'m COOL! \nNow sign my guestbook!'); } //--> </SCRIPT>Put it into the <HEAD> section of your document, then add the following into the BODY tag [after all the colours but before the >]:
onLoad="ok_box()"Click here to see how this script will work. Please note that you should never press ENTER when you're typing one line of code in JavaScript. Only press ENTER when you're ready to start another line; otherwise text should just go on continuously. Yes, I KNOW I pressed enter above, but that's because of the <PRE> tag I used to show you the code.
OnMouseOver="window.status='Link text here';return true" This is what it looks like [put your mouse over the word `This']But WAIT.. how do you make the text disappear??? Simple. After the code I just gave you, add the following code:
OnMouseOut="window.status='';return true"And the text will disappear when you move your mouse off the link. Here's how the code looks together:
OnMouseover="window.status='Link text here';return true" OnMouseOut="window.status='';return true" And this is what it looks like. [again, `this' is the word]Note that there is a function to do this, but there's too much to explain, and I'm too lazy. Go learn it somewhere else ;).
<SCRIPT LANGUAGE="JavaScript" TYPE=""> <!-- var yrname=prompt('Enter your name'); if ((yrname=='')||(yrname==null)||(yrname=='undefined')) { yrname="Person who cannot type" } //--> </SCRIPT>then add the following where you want the name the person typed in the document to go [hint: you can put it in multiple places, too!]:
<SCRIPT LANGUAGE="JavaScript" TYPE=""> <!-- document.write("Welcome, "+yrname+"!") //--> </SCRIPT>You can see how it works here. Try leaving the prompt field blank and see what happens :)