473,800 Members | 2,623 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Random Background image generator - Safari & mozilla problem

2 New Member
I am using the following code to call a random background image to be displayed on the far right hand side of the page ...

Expand|Select|Wrap|Line Numbers
  1. <script type="text/javascript">
  2. function random(n) {
  3. return Math.floor((Math.random() % 1) * n);
  4. }
  5. document.documentElement.style.background="url('photo"+[random(9)+1]+".jpg') repeat-y 890px 0 background-attachment: fixed"
  6. </script>
  7.  
This is working fine in explorer - but does not bring up the image in safari or mozilla ... any suggestions why this is happening ?
Jun 28 '07 #1
3 2745
acoder
16,027 Recognized Expert Moderator MVP
Welcome to TSDN!

What is documentElement ? On the far right of the page, what element do you have? Give it an id and try:
Expand|Select|Wrap|Line Numbers
  1. document.getElementById('theid').style.background=...
Jun 28 '07 #2
schof
2 New Member
Welcome to TSDN!

What is documentElement ? On the far right of the page, what element do you have? Give it an id and try:
Expand|Select|Wrap|Line Numbers
  1. document.getElementById('theid').style.background=...
Many thanks for this - 1st post answered really quickly ... um.. will give it a go and let u know what happens !

Tom
Jun 28 '07 #3
dreamcatcher
16 New Member
Hi Tom,

I'm looking into doing something similar to what you're describing. I've a background image (2 men+house) on: [code] www.zofocreativ e.com/groundsource/index2.htm[code] that I want to be able to change for random images.
Questions is: have you got yours working in Safari & Mozilla now. If you have, I'd like to see how you've done it if you don't mind. Thanks, S
Jun 28 '07 #4

Sign in to post your reply or Sign up for a free account.

Similar topics

2
9505
by: gene | last post by:
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...
0
1542
by: Jim Royal | last post by:
I'm having a weird refresh problem with a background image in IE 5.x for Windows. The problem is summed up here with screen shots: http://jimroyal.com/ie5_problem.html The background image becomes jumbled when the page is first viewed or refreshed. However, if you click any link, and then the Back button, the page is rendered correctly.
11
3206
by: Konrad Den Ende | last post by:
I have a function returning a string but the problem is that the color of it is blue which suits me well for some pages but not for others. Is it possible to "feel" what the color of the background in the current document is and set the color of the output accordingly? The background will be an image, in most cases. -- Kindly Konrad
3
4980
by: Greg Heilers | last post by:
Hello everyone... If one has a <div> that is completely filled with a background-image; how does one style it so that the image *continues* to fill the <div> top-to-bottom, left-to-right; if the viewer adjusts the font-size on his browser? I have everything sized in em's, so that the actual <div> "box" resizes along with the text, but the background-image will not resize if the text is "zoomed". I can not find anything pertaining
2
6496
by: Martin Honnen | last post by:
I was playing around with canvas support in recent Safari, Mozilla and Opera (only version 9 preview) but run into issues with Safari related to the very old DOM Level 0 Image object for preloading images. When doing e.g. var img = new Image(); img.onload = function (evt) { alert(this); }; img.src = 'whatever.gif';
12
5231
by: Jim Michaels | last post by:
I need to generate 2 random numbers in rapid sequence from either PHP or mysql. I have not been able to do either. I get the same number back several times from PHP's mt_rand() and from mysql's RAND(). any ideas? I suppose I could use the current rancom number as the seed for the next random number. but would that really work?
4
2758
by: tshad | last post by:
I am trying to set up an Image authorization where you type in the value that is in a picture to log on to our site. I found a program that is supposed to do it, but it doesn't seem to work. It should put a blue and yellow box on the page with "This is a test" as part of the picture. But what I get is a broken Gif. The other problem is that I can't view the source???? The view source is disabled for this page. What causes this?
2
2746
by: rigiditymodulus | last post by:
Hi - So, I had this working perfectly, then had a small crash (the transmitter for my wireless mouse occassionally freaks out my MacBook Pro) and when I rebooted and opened up my file the two layered DIVs I had were no longer showing up correctly. I had this going fine for several hours -- it wasn't a happy accident I forgot to save. I'm totally mystified on this one. Here's the summary: I want #container to be under #containerbranch, so...
6
1735
by: Fan924 | last post by:
How do I add random number generation to this background image slide show? Everything I try kills if. TIA _____________________________________ <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=windows-1252"> <meta name="GENERATOR" content="Microsoft FrontPage 4.0"> <meta name="ProgId" content="FrontPage.Editor.Document"> <title>New Page 2</title>
0
9691
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9551
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
10507
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
10279
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...
1
7582
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6815
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5607
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
3765
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2948
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.