473,394 Members | 2,052 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,394 software developers and data experts.

Can't get javascript/css random image placement to work in Mozilla

I have some javascript code that displays random images in random
places on the page by making changes to the document's css. This
works in Safari and IE, but I can't get it to work on Mozilla. Using
the javascript debugger, it seems that everything is working at that
end, so I wonder if the problem is mozilla/css related. The live page
is at http://www.smalltime.com/exhibitions/washanddry

Here is the relevant html and javascript code:

<head>
<script src="bubble.js" type="text/javascript"></script>
<style type="text/css" media="screen">
<!--
..bubbles { position: relative; top: 0; left: 0; z-index: 0; }
-->
</style>
</head>
<body onLoad="set_up();bubble();" onclick="bubble();">
<div id="div_1_1" class="bubbles"><img name="image_1_1"
src="bkgd/pixel.gif"></div>
<div id="div_2_1" class="bubbles"><img name="image_2_1"
src="bkgd/pixel.gif"></div>
<div id="div_1_2" class="bubbles"><img name="image_1_2"
src="bkgd/pixel.gif"></div>
<div id="div_2_2" class="bubbles"><img name="image_2_2"
src="bkgd/pixel.gif"></div>
<div id="div_3_2" class="bubbles"><img name="image_3_2"
src="bkgd/pixel.gif"></div>
<div id="div_1_3" class="bubbles"><img name="image_1_3"
src="bkgd/pixel.gif"></div>
<div id="div_2_3" class="bubbles"><img name="image_2_3"
src="bkgd/pixel.gif"></div>
<div id="div_3_3" class="bubbles"><img name="image_3_3"
src="bkgd/pixel.gif"></div>
<div id="div_4_3" class="bubbles"><img name="image_4_3"
src="bkgd/pixel.gif"></div>
</body>
</html>

bubble.js:
function bubble() {
var div_name;
var s;
var i;

for (i=0; i < img_3.length; ++i) {
div_name = "div_" + (i+1) + "_3";
s = getStyleObject(div_name);
s.top = Math.round(h*Math.random()) + "px";
s.left = Math.round(w*Math.random()) + "px";
s.zIndex=-3;
document.images[5+i].src=img_3_set[i];
}

for (i=0; i < img_2.length; ++i) {
div_name = "div_" + (i+1) + "_2";
s = getStyleObject(div_name);
s.top = Math.round(h*Math.random()) + "px";
s.left = Math.round(w*Math.random()) + "px";
s.zIndex=-2;
document.images[2+i].src=img_2_set[i];
}

for (i=0; i < img_1.length; ++i) {
div_name = "div_" + (i+1) + "_1";
s = getStyleObject(div_name);
s.top = Math.round(h*Math.random()) + "px";
s.left = Math.round(w*Math.random()) + "px";
s.zIndex=-1;
document.images[i].src=img_1_set[i];
}
}

function getStyleObject(objectId) {
if(document.getElementById && document.getElementById(objectId)) {
return document.getElementById(objectId).style;
} else if (document.all && document.all(objectId)) {
return document.all(objectId).style;
} else if (document.layers && document.layers[objectId]) {
return document.layers[objectId];
}
return false;
}
Jul 20 '05 #1
2 9488
gene wrote:
I have some javascript code that displays random images in random places on the page by making changes to the document's css. This works in Safari and IE, but I can't get it to work on Mozilla.
<snip>
s.zIndex=-3;
s.zIndex=-2;
s.zIndex=-1;

Unfortunately negative zIndexes are currently invisible in Mozilla :-(

--
Warning: May contain traces of nuts.

Jul 20 '05 #2
Neil <ne**@parkwaycc.co.uk> wrote in message news:<bn*********@ripley.netscape.com>...
gene wrote:
I have some javascript code that displays random images in random places on the page by making changes to the document's css. This works in Safari and IE, but I can't get it to work on Mozilla.

<snip>
s.zIndex=-3;
s.zIndex=-2;
s.zIndex=-1;

Unfortunately negative zIndexes are currently invisible in Mozilla :-(


I see. I stumbled on the negative zindexes after the positive values
didn't appear to be positioning things correctly. I guess I'll have
to resort to a browser detection hack for this. Thanks!
Jul 20 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

9
by: pablo | last post by:
Dear NGers, I would like to change the alt-text with the changing of the image during a mouseover action. Can document.images.altView be changed dynamically? TIA, pablo
2
by: Elisa | last post by:
I have two images, each with defined CSS hover states. I would like a mouseover on one image to trigger the hover state of the other image. Is this possible using javascript? If so, how? Any...
3
by: Jason | last post by:
I have two applications that I wrote that use asp and javascript source files. Recently both of these applications starting acting strange on my test box. Image icons will randomly stop showing...
7
by: x muzuo | last post by:
Hi guys, I have got a prob of javascript form validation which just doesnt work with my ASP code. Can any one help me out please. Here is the code: {////<<head> <title>IIBO Submit Page</title>...
8
by: Cat | last post by:
Greetings, I have an old javascript effect that was running on some of my sites for quite long, working fine in Netscape (up to 4.75) and IE. It still works in the newer IEs, but not in the new...
5
by: ZildjianB | last post by:
Hi All, I hope you can help me with this, as I have done some exhaustive searching over the past couple days and cannot find a solution. What I am trying to do is dynamically update an image...
0
by: Ken Dopierala Jr. | last post by:
Hi, I know this post will be considered off-topic. There are a lot of good coders in these groups and I'm hoping someone can help me out. This is what I'm working on. I used to use the...
9
by: WRH | last post by:
Hello I am new to asp but I made some Jscript functions which work fine. The functions contain some strings used as a registration key for some apps. It is important that these strings not be...
5
by: IndependentDreams | last post by:
This is a java script code that will make it snow on your page. My problem is that it works just fine in IE and Opera, but doesn't work in Fire Fox or Safari. Here is the code. If you have any idea...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.