Web Analytics Made Easy -
StatCounter Help with window.scroll() in IE - CodingForum

Announcement

Collapse
No announcement yet.

Help with window.scroll() in IE

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new 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
    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!||||

    Comment


    • #3
      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);
      		
      	}	
      	
      
      }

      Comment


      • #4
        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!||||

        Comment


        • #5
          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; Oct 12, 2006, 10:50 AM.

          Comment


          • #6
            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!||||

            Comment

            Working...
            X