Go Back   CodingForums.com > :: Client side development > JavaScript programming

Before you post, read our: Rules & Posting Guidelines

Reply
 
Thread Tools Rate Thread
Enjoy an ad free experience by logging in. Not a member yet? Register.
Old 10-12-2006, 03:06 AM   PM User | #1
helios02
New to the CF scene

 
Join Date: Oct 2006
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
helios02 is an unknown quantity at this point
Help with window.scroll() in IE

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.
helios02 is offline   Reply With Quote
Old 10-12-2006, 04:59 AM   PM User | #2
_Aerospace_Eng_
Supreme Master coder!


 
_Aerospace_Eng_'s Avatar
 
Join Date: Dec 2004
Location: In a place far, far away...
Posts: 19,293
Thanks: 2
Thanked 1,044 Times in 1,020 Posts
_Aerospace_Eng_ is a glorious beacon of light_Aerospace_Eng_ is a glorious beacon of light_Aerospace_Eng_ is a glorious beacon of light_Aerospace_Eng_ is a glorious beacon of light_Aerospace_Eng_ is a glorious beacon of light
Its window.scrollTo(0,0) not window.scroll(0,0)
__________________
||||If you are getting paid to do a job, don't ask for help on it!||||
_Aerospace_Eng_ is offline   Reply With Quote
Old 10-12-2006, 06:13 AM   PM User | #3
helios02
New to the CF scene

 
Join Date: Oct 2006
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
helios02 is an unknown quantity at this point
I've tried that too, and it doesn't seem to work. Here is the function I'm using: (works in Firefox and Safari)

Code:
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);
		
	}	
	

}
helios02 is offline   Reply With Quote
Old 10-12-2006, 06:36 AM   PM User | #4
_Aerospace_Eng_
Supreme Master coder!


 
_Aerospace_Eng_'s Avatar
 
Join Date: Dec 2004
Location: In a place far, far away...
Posts: 19,293
Thanks: 2
Thanked 1,044 Times in 1,020 Posts
_Aerospace_Eng_ is a glorious beacon of light_Aerospace_Eng_ is a glorious beacon of light_Aerospace_Eng_ is a glorious beacon of light_Aerospace_Eng_ is a glorious beacon of light_Aerospace_Eng_ is a glorious beacon of light
Can you show us the html you tried and said it didn't work?
__________________
||||If you are getting paid to do a job, don't ask for help on it!||||
_Aerospace_Eng_ is offline   Reply With Quote
Old 10-12-2006, 02:48 PM   PM User | #5
helios02
New to the CF scene

 
Join Date: Oct 2006
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
helios02 is an unknown quantity at this point
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:
Code:
<!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>

Last edited by helios02; 10-12-2006 at 02:50 PM..
helios02 is offline   Reply With Quote
Old 10-12-2006, 05:38 PM   PM User | #6
_Aerospace_Eng_
Supreme Master coder!


 
_Aerospace_Eng_'s Avatar
 
Join Date: Dec 2004
Location: In a place far, far away...
Posts: 19,293
Thanks: 2
Thanked 1,044 Times in 1,020 Posts
_Aerospace_Eng_ is a glorious beacon of light_Aerospace_Eng_ is a glorious beacon of light_Aerospace_Eng_ is a glorious beacon of light_Aerospace_Eng_ is a glorious beacon of light_Aerospace_Eng_ is a glorious beacon of light
Okay and you are trying to scroll the page scrollbar or a scrollbar that inside of an element?
__________________
||||If you are getting paid to do a job, don't ask for help on it!||||
_Aerospace_Eng_ is offline   Reply With Quote
Reply

Bookmarks

Jump To Top of Thread


Thread Tools
Rate This Thread
Rate This Thread:

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

Forum Jump


All times are GMT +1. The time now is 08:11 AM.


Advertisement
Log in to turn off these ads.