View Full Version : Changing a webpages background by clicking a link/image?
Topps
22-08-2007, 05:08 PM
If you know what I mean by the title, I need something where you click a link and it changes the background to a different image? :)
Swearwolf
22-08-2007, 06:24 PM
yeah.
<script language="JavaScript">
<!--
var backImage = new Array(); // don't change this
// Enter the image filenames you wish to use.
// Follow the pattern to use more images. The
// number in the brackets [] is the number you
// will use in the function call to pick each
// image.
// Note how backImage[3] = "" -- which would
// set the page to *no* background image.
backImage[0] = "bg1.gif";
backImage[1] = "bg2.gif";
backImage[2] = "bg3.gif";
backImage[3] = "";
// Do not edit below this line.
//-----------------------------
function changeBGImage(whichImage){
if (document.body){
document.body.background = backImage[whichImage];
}
}
//-->
</script>
</textarea>
</form>
</td>
</tr>
<a href="javascript:changeBGImage(0)">Change 1</a>
<a href="javascript:changeBGImage(1)">Change 2</a>
<a href="javascript:changeBGImage(2)">Change 3</a>
<a href="javascript:changeBGImage(3)">No Background</a>
working example:
www.habbo-club.co.uk/background.htm (http://www.habbo-club.co.uk/background.htm)
Topps
22-08-2007, 07:18 PM
yeah.
<script language="JavaScript">
<!--
var backImage = new Array(); // don't change this
// Enter the image filenames you wish to use.
// Follow the pattern to use more images. The
// number in the brackets [] is the number you
// will use in the function call to pick each
// image.
// Note how backImage[3] = "" -- which would
// set the page to *no* background image.
backImage[0] = "bg1.gif";
backImage[1] = "bg2.gif";
backImage[2] = "bg3.gif";
backImage[3] = "";
// Do not edit below this line.
//-----------------------------
function changeBGImage(whichImage){
if (document.body){
document.body.background = backImage[whichImage];
}
}
//-->
</script>
</textarea>
</form>
</td>
</tr>
<a href="javascript:changeBGImage(0)">Change 1</a>
<a href="javascript:changeBGImage(1)">Change 2</a>
<a href="javascript:changeBGImage(2)">Change 3</a>
<a href="javascript:changeBGImage(3)">No Background</a>
working example:
www.habbo-club.co.uk/background.htm (http://www.habbo-club.co.uk/background.htm)
Thanks a billion and over, you're amazing! :eusa_danc
Swearwolf
22-08-2007, 07:45 PM
you're more than welcome
Topps
22-08-2007, 09:26 PM
One last question, can I put the links in an iframe and put the iframe on a page and it changes the page with the iframe on, I tried target="_parent" but it didn't work...
Swearwolf
22-08-2007, 09:34 PM
should be able to
ill have a look
*edit*
i cant seem to figure out how you would go about doing this because they are javascript links, they cant open in a new frame correctly...
all i can suggest is if you have a coded layout etc you could create an extra cell near the navigation or w.e you want the links to be and put all the code on same page, all i can think of
Topps
22-08-2007, 09:47 PM
What about an include? Would that make it open on the main page its changing?
Edit that, I need a scroll bar to be there.
OK, it's like a Habbo Home Script, but you click BackGrounds and a box pops up in a frame and you choose the background you'd like to change it to.
Want to hide these adverts? Register an account for free!
Powered by vBulletin® Version 4.2.5 Copyright © 2024 vBulletin Solutions Inc. All rights reserved.