Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 6 of 6
  1. #1
    New to the CF scene
    Join Date
    Oct 2006
    Posts
    3
    Thanks
    0
    Thanked 0 Times in 0 Posts

    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.

  • #2
    Supreme Master coder! _Aerospace_Eng_'s Avatar
    Join Date
    Dec 2004
    Location
    In a place far, far away...
    Posts
    19,291
    Thanks
    2
    Thanked 1,043 Times in 1,019 Posts
    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!||||

  • #3
    New to the CF scene
    Join Date
    Oct 2006
    Posts
    3
    Thanks
    0
    Thanked 0 Times in 0 Posts
    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);
    		
    	}	
    	
    
    }

  • #4
    Supreme Master coder! _Aerospace_Eng_'s Avatar
    Join Date
    Dec 2004
    Location
    In a place far, far away...
    Posts
    19,291
    Thanks
    2
    Thanked 1,043 Times in 1,019 Posts
    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!||||

  • #5
    New to the CF scene
    Join Date
    Oct 2006
    Posts
    3
    Thanks
    0
    Thanked 0 Times in 0 Posts
    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 03:50 PM.

  • #6
    Supreme Master coder! _Aerospace_Eng_'s Avatar
    Join Date
    Dec 2004
    Location
    In a place far, far away...
    Posts
    19,291
    Thanks
    2
    Thanked 1,043 Times in 1,019 Posts
    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!||||


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •