Tycoon Talk
Become a Big fish!
The number 1 forum for online business!
Post topics, ask questions, share your knowledge.
Tycoon Talk is part of Freelancer.com - find skilled workers online at a fraction of the cost.

JavaScript Forum


You are currently viewing our JavaScript Forum as a guest. Please register to participate.
Login



Reply
jscript not working firefox
Old 05-26-2007, 01:00 PM jscript not working firefox
Junior Talker

Posts: 1
Trades: 0
heres my code...it doesnt work in firefox >> example website (http://spoonie3372.tirpod.com/index.html)

CODE::

<head>
<SCRIPT LANGUAGE="JavaScript">
<!--
var backgroundset=false;
function fixedBackground(url)
{
if(!backgroundset)
{
document.body.style.overflow = 'hidden';
document.body.style.padding = '0px';
document.body.style.margin = '0px';

var overlay = document.createElement('DIV');
overlay.style.position = 'absolute';
overlay.style.top = '0px';
overlay.style.left = '0px';
overlay.style.height = '100%';
overlay.style.width = '100%';
overlay.style.overflow = 'auto';

overlay.innerHTML = document.body.innerHTML;
document.body.innerHTML = '<img id="background" height="100%" width="100%" src="' + url + '" style="left: 0; bottom: 0; right: 0; top: 0; z-index: 0" />';

document.body.appendChild(overlay);

backgroundset=true;
}
else
background.src=url;
}
//-->
</SCRIPT>

<title>
TESTING
</title>
</head>
<body onload="fixedBackground('clouds-03.jpg');">
spoonie3372 is offline
Reply With Quote
View Public Profile
 
 
Register now for full access!
Old 05-26-2007, 04:25 PM Re: jscript not working firefox
tripy's Avatar
Do not try this at home!

Posts: 3,621
Name: Thierry
Location: I'm the uber Spaminator !
Trades: 0
Well, I got it working in FF with your code, but your mixing old style js coding and dom manipulation.
Why not go all the way through dom ?

I suggest you split that in 2 files, and most important, that you validate your HTML before all.

The html:
Code:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"
   "http://www.w3.org/TR/html4/strict.dtd">
<html>
    <head>
        <title>
        TESTING
        </title>
        <script src="bg.js" type="text/javascript"/>
    </head>
    <body onload="fixedBackground('http://www.webmaster-talk.com/bluesky/vb_img/logo.gif')">
        <br/>
    </body>
</html>
And then for the js:
Code:
var backgroundset=false;
function fixedBackground(url){
    if(!backgroundset){
        var _body=document.getElementsByTagName("body")[0];
        _body.style.overflow = 'hidden';
        _body.style.padding = '0px';
        _body.style.margin = '0px';
        
        var overlay = document.createElement('DIV');
        overlay.style.position = 'absolute';
        overlay.style.top = '0px';
        overlay.style.left = '0px';
        overlay.style.height = '100%';
        overlay.style.width = '100%';
        overlay.style.overflow = 'auto';
        
        var bgImg=document.createElement('img');
        bgImg.id="background";
        bgImg.style.height="100%";
        bgImg.style.width="100%";
        bgImg.src=url;
        
        overlay.appendChild(bgImg);
        _body.appendChild(overlay);
        
        backgroundset=true;
    }
    else{
        background.src=url;
    }
}
__________________
Only a biker knows why a dog sticks his head out the window.
tripy is offline
Reply With Quote
View Public Profile Visit tripy's homepage!
 
Reply     « Reply to jscript not working firefox
 

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off





   
RSS Feed  Feeds: RSS   JS   XML
RSS Feed  Feeds for this forum: RSS   JS   XML



Page generated in 0.09917 seconds with 12 queries