开发者

How do I determine where this javascript is coming from?

开发者 https://www.devze.com 2022-12-18 06:05 出处:网络
So I\'ve been handed an older website, and been asked to make some modifications. It\'s been made with ASP, and I\'m not really familiar with it. http://www.littleairplane.com/who-we-are/default.aspx

So I've been handed an older website, and been asked to make some modifications. It's been made with ASP, and I'm not really familiar with it. http://www.littleairplane.com/who-we-are/default.aspx I've been asked to get rid of that awful scrolling.

By looking at the page source, I determined that the scrolling is done using some inline Javascript.

    <script type="text/javascript">

  function getElementPosition(theElement){
    var posX = 0;
    var posY = 0;           
    while(theElement != null){
      posX += theElement.offsetLeft;
      posY += theElement.offsetTop;
      theElement = theElement.offsetParent;          
    }                                     
   return {x:posX, y:posY};
  }

  var offsetY = 0;
  window.onload = function(){

    var elem = document.getElementById("foo");
    var elemPos = getElementPosition(elem);

    var box = document.getElementById("boxId");
    box.style.left = elemPos.x + "px";
    box.style.top = elemPos.y + "px";
    offsetY = elemPos.y;

    elem = null;
    box = null;

  }
  window.onscroll = function(){
    var scrollY = (window.pageYOffset)?(window.pageYOffset):(document.documentElement)?document.documentElement.scrollTop:document.body.scrollTop;
    var box = document.getElementById("boxId");
    box.style.top = (offsetY + scrollY) + "px";
    box = null;
  }

</script>

I would love t开发者_运维知识库o comment it out, but since it's ASP I'm not sure where to find that javascript. The default.ASP file I have doesn't contain it. And from what I can tell there is no call to an external .js file.

The only thing I could find was a java.htm file at the root which has the code I'm looking for, but It doesn't seem to matter whether or not that file is there.

So I'd like to know how to find that javascript. Any help is greatly appreciated.


Use FireBug and activate the Script tab.

There is a dropdown list of all the javascripts that are on the page, and their source paths.

If you run into source paths that contain "WebResource.axd?crazycrazystringofguidylookingstuff....", then you know that there are scripts being compiled into the dll as an embedded resource. Once you have the script text though, you can do a global find in your code to see where it's located.


Looks like it's been included somewhere... do a "Find..." for something like:

<!--#include

Also, it's kind of hacky, but you could set the window.onscroll event to null in javascript, at the very bottom of the master page?


You can step through asp in visual studio, if you have it. Alternatively you could try grepping through the code base. ASP surrounds its own code in tags (like JSP), so the javascript (or at least things other than specific element names) should be contiguous.

0

精彩评论

暂无评论...
验证码 换一张
取 消