Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

using images with javascript

Status
Not open for further replies.

johnsimpson

Programmer
Mar 28, 2006
60
GB
ok really basic question here,

how can display an image depending on a if statement?

im using the following code:

<script language="JavaScript1.2">
if (pr != ""){
document.write("Please wait while the page is loaded");
}
</script>

But i want to add an image before the please wait while page is loading bit - so it will display a preloader image.

sorry its very basic i know ;-)
 
Yes, just insert an image tag into the document.write line in your script right before the "Please wait...."
Or just put the image tag in HTML prior to the script.

You will of course want the above script to be inside the BODY tags, not the HEAD as you are writing HTML to the page which should be inside the body.


It's hard to think outside the box when I'm trapped in a cubicle.
 
ahhhhhhh.... it was because i was using " instead of '

thanks guys

J
 
If you use Firefox and look in the JavaScript console, these errors are pointed out to you.

Download and install it (and choose to install the developer options) - you'll become much better at debugging these things with it.

Dan

Coedit Limited - Delivering standards compliant, accessible web solutions

[tt]Dan's Page [blue]@[/blue] Code Couch
[/tt]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top