...

View Full Version : Help with window.scroll() in IE



helios02
10-12-2006, 04:06 AM
I'm doing some simple Flash/Javascript communication, and I can't seem to be able to get the scrollbar to adjust to a certain point in my IE6.. I'm just doing a simple window.scroll(0,0). This works fine in Firefox, Safari, and any other browser I test except IE6. Does anyone know have an explanation for this? I even tried just simple examples without any Flash, and it still won't work.

_Aerospace_Eng_
10-12-2006, 05:59 AM
Its window.scrollTo(0,0) not window.scroll(0,0)

helios02
10-12-2006, 07:13 AM
I've tried that too, and it doesn't seem to work. Here is the function I'm using: (works in Firefox and Safari)


function scrollFunc(scrollLoc){

//alert(scrollLoc);

if (self.pageYOffset) // all except Explorer
{

window.scroll(0, scrollLoc);

}
else if (document.documentElement && document.documentElement.scrollTop)
// Explorer 6 Strict
{

window.scrollTo(0, scrollLoc);
}
else if (document.body) // all other Explorers
{

window.scrollTo(0, scrollLoc);

}


}

_Aerospace_Eng_
10-12-2006, 07:36 AM
Can you show us the html you tried and said it didn't work?

helios02
10-12-2006, 03:48 PM
Well, I'm calling that JavaScript function from Flash using a getURL() (I don't know if you're familiar with that). But inside of my ActionScript, I just have

getURL('javascript:scrollFunc('+ yOffset + ');');


The html looks like:


<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Loveworn</title>

<script type="text/javascript" src="swfobject.js"></script>
<script type="text/javascript">
<!--
function resizeSWF(nHeight, nWidth, mcName) {

if(mcName == "workList"){
nHeight*=.8;
}
//alert(mcName);
nHeight += "px";
nWidth += "px";
document.getElementById("loveworn").style.height = nHeight;
document.getElementById("loveworn").style.width = nWidth;
}


function getScroll(){
var x,y;

if (self.pageYOffset) // all except Explorer
{
x = self.pageXOffset;
y = self.pageYOffset;
}
else if (document.documentElement && document.documentElement.scrollTop)
// Explorer 6 Strict
{
x = document.documentElement.scrollLeft;
y = document.documentElement.scrollTop;
document.getElementById("loveworn").setVariable("yOffset", y);
}
else if (document.body) // all other Explorers
{
x = document.body.scrollLeft;
y = document.body.scrollTop;
}

window.document.loveworn.SetVariable("yOffset", y);

}


function scrollFunc(scrollLoc){

//alert(scrollLoc);
if (self.pageYOffset) // all except Explorer
{

window.scroll(0, scrollLoc);

}
else if (document.documentElement && document.documentElement.scrollTop)
// Explorer 6 Strict
{

window.scrollTo(0, scrollLoc);
}
else if (document.body) // all other Explorers
{

window.scrollTo(0, scrollLoc);

}


}


//-->
</script>
<style type="text/css">
body {
margin: 0;
background-color: #0E0E0E;
}
#flashcontent {
//width: 100%;
margin: 0 auto;
}
</style>
</head>
<body>

<div id="flashcontent">

<strong>You need to upgrade your Flash Player</strong>
will put link here later.
</div>

<script type="text/javascript">
// <![CDATA[
var so = new SWFObject("loveworn.swf", "loveworn", "0", "0", "8");
so.addParam("scale", "noscale");
so.addParam("swLiveConnect", "true");


if( typeof( window.innerWidth ) == 'number' ) {
//Non-IE
so.addVariable("bWidth", window.innerWidth-20);
so.addVariable("bHeight", window.innerHeight);
}
else if( document.documentElement && ( document.documentElement.clientWidth || document.documentElement.clientHeight ) ) {
//IE 6+ in 'standards compliant mode'

so.addVariable("bWidth", document.documentElement.clientWidth-20);
so.addVariable("bHeight", document.documentElement.clientHeight);
}


so.write("flashcontent");
// ]]>
</script>

</body>

</html>

_Aerospace_Eng_
10-12-2006, 06:38 PM
Okay and you are trying to scroll the page scrollbar or a scrollbar that inside of an element?



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum