locked
why would jscript work in .html page but not .aspx page RRS feed

  • Question

  • I have the following in my page and if we create and use this within a html page it all works.. if we use this within a aspx page it doesnt work... 
    
     
    
    <script type="text/jscript" language="jscript"> 
    <!-- 
     
      document.onreadystatechange = onVLCStateChange; 
      function onVLCStateChange() { 
        if (document.readyState == 'complete') { 
          //updateVolume(0); 
        } 
      }; 
      //function slider::Scroll() 
      function slider_Scroll() { 
        var vlc = document.getElementById("vlc"); 
        var slider = document.getElementById("slider"); 
        var oldPos = vlc.input.position; 
        var newPos = slider.Value / slider.width; 
        if ((vlc.input.state == 3) && (oldPos != newPos)) { 
          vlc.input.position = newPos; 
          slider.Text = formatTime(vlc.input.time); 
          document.getElementById("info").innerHTML = slider.Text + "/" + formatTime(vlc.input.length); 
        } 
        sliderScrolling = true; 
      }; 
      //function slider::Change() 
      function slider_Change() { 
        var vlc = document.getElementById("vlc"); 
        var slider = document.getElementById("slider"); 
        var oldPos = vlc.input.position; 
        var newPos = slider.Value / slider.width; 
        if (sliderScrolling) { 
          sliderScrolling = false; 
        } 
        else if (!ignoreSliderChange && (vlc.input.state == 3) && (oldPos != newPos)) { 
          vlc.input.position = newPos; 
        } 
      }; 
    //-->   
    </script>
    
    Wednesday, March 30, 2011 10:27 PM

All replies

  • One reason why it would not work in an ASPX page is because ASP.NET generates client side id values which don't match the ones you try to reference using getElementById.  Check the source code to see if this is actually the root of your problem.

     

    Sunday, April 3, 2011 1:08 PM
  • 1,change 

    <script type="text/jscript" language="jscript">

    to

    <script type="text/javascript" language="javascript">

     

    because jscript ONLY works in IE

    2,if you reference a Server Web Control's ID,you need to use ClientID Arrtibute,for example:

    document.getElementById("<%=info.ClientID%>")

    <asp Label id=info runst=server

     

     



    【孟子E章】
    Sunday, April 3, 2011 1:14 PM