Solved

fixed background image in Mozilla?

Posted on 2004-08-12
4
165 Views
Last Modified: 2010-04-06
Hi, I am trying to show a background jpeg that stays in a fixed position even when the window is scrolled. My code works fine in IE6 but only half-works in Mozilla/Firefox. In Moz it either does not appear at all or it appears and sets the background of the rest of the page white. Seems to be the no-repeat option that Moz does not like, but I must have that feature, I only want 1 copy of the picture.

I have also tried using HTML/css in the header section but get exactly the same results!
Please help, this is driving me nuts!

code in body section:

<script language="JavaScript1.2">
    if (document.all||document.getElementById) {
        document.body.style.background="url('nirvana.png') black left no-repeat fixed";
    }
</script>

0
Comment
Question by:azriel_99
  • 2
  • 2
4 Comments
 
LVL 3

Accepted Solution

by:
Belthazor earned 500 total points
ID: 11790865
Hi,
This code ....
-------------------------------------------------------------------------------
<html>

<head>
<script type="text/javascript">
function ChangeColor()
{
    if (document.all||document.getElementById) {
      document.body.style.background="url('nirvana.png') black left no-repeat fixed";
     }
}
</script>
</head>

<body onLoad="ChangeColor()">
Content
</body>

</html>
---------------------------------------------------------------------------------------

.. works in both IE and Firefox

Belthazor
0
 

Author Comment

by:azriel_99
ID: 11792184
thou art a gentleman and a scholar, and a shagmeister
thanks Belthazor! for extra karma could you tell me the technical reason why that works as opposed to my code?
cheers!
0
 
LVL 3

Expert Comment

by:Belthazor
ID: 11792687
hi azriel_99,
i think this is because you can not access the 'document.body'-object before initializing it (it gets initialized where the <body> tag is), because when you take the whole <script>....</script> tag into your body, its gonna work too, but if i were you, i would keep the function.
I like to use functions because you can call them whereever you want and as many times you want, and you can write all of them into the <head> tag, so all of your script is in a single <script> tag!

Belthazor
0
 

Author Comment

by:azriel_99
ID: 11794008
ahh I guess that makes sense. I am new to this web programming stuff - it certainly is quirky! thanks a lot, may jewels and sweet meats rain upon you!
0

Featured Post

PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
From XSL to Word - How add a page break? 5 35
Xsl Nested Loop 4 29
selectSingleNode in Access 2013 11 59
Re-position sub-options beneath the TAB 7 88
Preface In the first article: A Better Website Login System (http://www.experts-exchange.com/A_2902.html) I introduced the EE Collaborative Login System and its intended purpose. In this article I will discuss some of the design consideratio…
SASS allows you to treat your CSS code in a more OOP way. Let's have a look on how you can structure your code in order for it to be easily maintained and reused.
The viewer will learn how to look for a specific file type in a local or remote server directory using PHP.
The viewer will the learn the benefit of plain text editors and code an HTML5 based template for use in further tutorials.

773 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question