Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

fixed background image in Mozilla?

Posted on 2004-08-12
4
Medium Priority
?
172 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
  • 2
4 Comments
 
LVL 3

Accepted Solution

by:
Belthazor earned 2000 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

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

This article covers the basics of the Sass, which is a CSS extension language. You will learn about variables, mixins, and nesting.
Without even knowing it, most of us are using web applications on a daily basis.  In fact, Gmail and Yahoo email, Twitter, Facebook, and eBay are used by most of us daily—and they are web applications. We generally confuse these web applications to…
Viewers will learn about if statements in Java and their use The if statement: The condition required to create an if statement: Variations of if statements: An example using if statements:
This tutorial will teach you the core code needed to finalize the addition of a watermark to your image. The viewer will use a small PHP class to learn and create a watermark.

721 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