|
Answer» Hi!,
I have searched very long to a working html or javascript code for a random background on my website. My website uses frames as you can see. Please take a look at my website>>
http://v4.livegate.net/sjkastronomy/home.html
I want a random background in the navigator bar at the LEFT HAND side.
As you typ in http://v4.livegate.net/sjkastronomy/image1.jpg in the browser, the background is displayed. I want that background and 9 others, randomly displayed on that navigator bar.
I already have put a code on my website, as it was told to do >> http://www.groan-zone.net/jscript/random.html
When I install this code on my website (offline), it works! I used this code between the tags:
and this code in stead of the tag
When I upload the panel.html, with the installed code, I does not work.
I also tried to change the code as you can see here: ((with the full image adress behind the images "http://v4.livegate.net/sjkastronomy/"))
But it still does not work!
Can somebody please help me??
I searched very long for the code, but I still COULD not find it. I think it does not work, because my website uses frames. But I don't know and could not fnd the proper code for it.
Sander Klieverik Hi!,
I have found the solution. THANKS for everybody reading this topic. For other people, sharing the same problem, you can see what you have to do with a random background javascript code, when your website contains frames.
This is the code you must USE between the tags:
if (parent.frames.length==0) window.location.replace("index.html")
onload = function() { // set up an array of the images images = new Array("image1.jpg", "image2.jpg","image3.jpg","image4.jpg","image5.jpg","image6.jpg","image7.jpg","image8.jpg","image9.jpg","image10.jpg"); rand = Math.floor(Math.random()*images.length); // choose a random number, between 0 and the length of the array -1 img = images[rand] // set img to the random image's src document.body.style.background= "url("+img+")"; // set the background image }
Sander Klieverik
|