/    Sign up×
Community /Pin to ProfileBookmark

problem getting this javascript work in all browsers

Hi all,

Here’s the problem.. I made a swf for a site that has an animated background, therefore a large witdh to cover resolutions up to 1280×1024.
Content-part in this swf is small in width so it doesnt need a scroll for resolutions starting from 800×600.

here you can see what i came up with, together with the help of a friend:

[URL=http://www.spiritz.nl/test/index.html]link to example[/URL]

(the yellow is the content, the red the animated background)

my code:

[CODE]
<!DOCTYPE html PUBLIC “-//W3C//DTD HTML 4.0 Transitional//EN”>
<html><head>
<title></title>
<meta http-equiv=”Content-Type” content=”text/html; charset=iso-8859-1″>
<style type=”text/css”>
html,body { overflow-x:hidden;
}
</style>

[COLOR=DarkRed]<script language=”javascript”>
function moveWin(){
var winW = 630, winH = 460;
if (parseInt(navigator.appVersion)>3) {
if (navigator.appName==”Netscape”) {
winW = window.innerWidth;
}
if (navigator.appName.indexOf(“Microsoft”)!=-1) {
winW = document.body.offsetWidth;
}
}
var movieWidth = 1230;
var winleft = (movieWidth/2) – (winW/2);
scrollTo(winleft, 0);
}
</script>[/COLOR]

</head>
<body bgcolor=”#FFFFFF” topmarginb=”0″ leftmargin=”0″ [COLOR=DarkRed]onload=”moveWin()” onResize=”moveWin()”[/COLOR]>
<center>

<object classid=”clsid: D27CDB6E-AE6D-11cf-96B8-444553540000″
codebase=”http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,79,0″
id=”main” width=”1230″ height=”700″>
<param name=”movie” value=”main.swf”>
<param name=”bgcolor” value=”#777777″>
<param name=”quality” value=”best”>
<param name=”allowscriptaccess” value=”samedomain”>
<embed type=”application/x-shockwave-flash”
pluginspage=”http://www.macromedia.com/go/getflashplayer”
width=”1230″ height=”700″
name=”main” src=”main.swf”
bgcolor=”#777777″ quality=”best”
swLiveConnect=”true” allowScriptAccess=”samedomain”
></embed>
</object>

</center><br>
</body>
</html>
[/CODE]

[COLOR=DarkRed]Now my problem is this does work in Internetexplorer and Maxthon, but not in Mozilla and Firefox…[/COLOR]

I used the css to remove the horizontal scrollbar, since the background doesnt have to show completely. This also only works in IE and Maxthon, but this is of minor importance.

Anyone got a clue why it doesnt and how I can solve this? Thx in advance!

to post a comment
JavaScript

2 Comments(s)

Copy linkTweet thisAlerts:
@KorFeb 28.2005 — Try

...

if (navigator.appName=="Netscape") {

winW = window.innerWidth;

}

else {

winW = document.getElementsByTagName('body')[0].offsetWidth;

}

...
Copy linkTweet thisAlerts:
@RedDragonauthorFeb 28.2005 — Great!!

it works in firefox, mozilla, internet explorer and maxthon. no other browsers on my pc ..

Thanks a lot, much appreciated!
×

Success!

Help @RedDragon spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 6.2,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @meenaratha,
tipped: article
amount: 1000 SATS,

tipper: @meenaratha,
tipped: article
amount: 1000 SATS,

tipper: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,
)...