473,654 Members | 3,108 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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*Ma th.random()) + "px";
s.left = Math.round(w*Ma th.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*Ma th.random()) + "px";
s.left = Math.round(w*Ma th.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*Ma th.random()) + "px";
s.left = Math.round(w*Ma th.random()) + "px";
s.zIndex=-1;
document.images[i].src=img_1_set[i];
}
}

function getStyleObject( objectId) {
if(document.get ElementById && document.getEle mentById(object Id)) {
return document.getEle mentById(object Id).style;
} else if (document.all && document.all(ob jectId)) {
return document.all(ob jectId).style;
} else if (document.layer s && document.layers[objectId]) {
return document.layers[objectId];
}
return false;
}
Jul 20 '05 #1
2 9502
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.netsc ape.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
3719
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
3071
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 help would be appreciated. Thanks, CJ
3
1667
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 up and any javascript that I use a src file with <script language="javascript" src="mytest.js"></script> ) returns random errors. Javascript on the page itself works fine. If I click f5 multiple times I will get different results. I am...
7
3593
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> </head> <style type="text/css">
8
1495
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 Mozillas, neither Firebird nor Firefox (and not in Netscape 7.something). What is wrong with it? I'm no javascript expert, I just got it from the net years ago, I don't even know where from. There is no source url given in it to look up. I've...
5
7140
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 and image map on a page. I'd like the update to happen as quickly as possible and be done without refreshing the page. The catch is that the image map uses the wz_tooltip.js (http://www.walterzorn.com/tooltip/tooltip_e.htm) library to display a...
0
1286
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 webservice.htc alot, but now I have to code for Netscape and Mozilla and it didn't work. This was a good thing, the webservice.htc would choke if you sent back things like arraylists so I wrote my own wrapper. No matter what you send (dataset, array,...
9
3334
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 visible to a client using a browser. My question is...can a knowledgeable browser user view Jscript source code in an asp file?
5
2290
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 why i can't get it to work that would be great! <!-- this script got from www.javascriptfreecode.com-Coded by: Krishna Eydatoula --> <!-- Web Site: http://www.javakhafan.9f.com--> <!-- javakhafan.9f.com --> <script> // Set the number of...
0
8285
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
8814
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
8706
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
8591
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
4149
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4293
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2709
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
1
1915
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
2
1592
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.