Forum Moderators: open

Message Too Old, No Replies

Picture/Banner to disappear after click

I need a javascript that will make a banner disappear after click, but not

         

patiolanterns

11:42 pm on Apr 23, 2008 (gmt 0)

10+ Year Member



I hope I can explain what I am looking for.

I want to have a webpage with a background picture(possibly in a table) that will be covered by approx. 18 other smaller pictures.

When someone clicks the smaller pictures, I want them to go to that sites page (either in a new tabbed browser, or new page, but not leave the main page and that picture to disappear revealing the larger background picture underneath.

Any help would be greatly appreciated!

httpwebwitch

6:01 pm on Apr 25, 2008 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



This sounds like a "reveal the image" game.
OK, to start, you'll be applying an onclick event to those images.

<img onclick="reveal(this)" src="whatever.jpg" />

when someone clicks, do the two things you want to happen: hide the image, and open a new window.

put this in your <head>:
<script>
function reveal(elem){
elem.style.visible='hidden';
window.open(url,winname,options); // see the window.open command reference for tips
}
</script>

Going forward you'll need some way to tell reveal() which URL will be opened - I'm assuming each image will have a different URL - but this ought to get you started.

httpwebwitch

6:01 pm on Apr 25, 2008 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



welcome to WebmasterWorld, patiolanterns!