Forum Moderators: open

Message Too Old, No Replies

Display image if a certain url

         

MWpro

2:12 pm on Oct 18, 2004 (gmt 0)

10+ Year Member



How would you display/hide an image with javascript based on the page's url? For example:


if(url=www.example.com/index.html){
display image;
} else {
hide image;
}

[edited by: DrDoc at 8:10 pm (utc) on Oct. 18, 2004]
[edit reason] examplified URL [/edit]

Cook

3:08 pm on Oct 18, 2004 (gmt 0)

10+ Year Member



You could use JavaScript to dynamically change the display style attribute of your img. Set display to block or inline to show it, to none to not show it.
Cheers,
Cook

MWpro

7:27 pm on Oct 18, 2004 (gmt 0)

10+ Year Member



Good idea. What about the "if" part though.

Cook

11:04 pm on Oct 18, 2004 (gmt 0)

10+ Year Member



JavaScript's window.location is read/write, so you can use it to test the currently displayed url.

Cheers,
Cook