简体   繁体   English

如何确定此javascript的来源?

[英]How do I determine where this javascript is coming from?

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. 它是用ASP制作的,我对此并不十分熟悉。 http://www.littleairplane.com/who-we-are/default.aspx I've been asked to get rid of that awful scrolling. http://www.littleairplane.com/who-we-are/default.aspx我被要求摆脱那可怕的滚动。

By looking at the page source, I determined that the scrolling is done using some inline Javascript. 通过查看页面源,我确定使用某些内联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 to comment it out, but since it's ASP I'm not sure where to find that javascript. 我想将其注释掉,但是由于它是ASP,所以我不确定在哪里可以找到该javascript。 The default.ASP file I have doesn't contain it. 我拥有的default.ASP文件不包含它。 And from what I can tell there is no call to an external .js file. 从我可以看出,没有对外部.js文件的调用。

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. 我唯一能找到的是根目录下的java.htm文件,其中包含我要查找的代码,但是该文件是否存在似乎并不重要。

So I'd like to know how to find that javascript. 因此,我想知道如何找到该javascript。 Any help is greatly appreciated. 任何帮助是极大的赞赏。

Use FireBug and activate the Script tab. 使用FireBug并激活“脚本”选项卡。

There is a dropdown list of all the javascripts that are on the page, and their source paths. 页面上的所有Javascript及其源路径都有一个下拉列表。

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. 如果您遇到包含“ WebResource.axd?crazycrazystringofguidylookingstuff ....”的源路径,那么您就会知道有脚本正在作为嵌入式资源编译到dll中。 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? 另外,它有点hacky,但是您可以在母版页最底部将javascript中的window.onscroll事件设置为null

You can step through asp in visual studio, if you have it. 如果有的话,您可以在Visual Studio中逐步浏览ASP。 Alternatively you could try grepping through the code base. 或者,您可以尝试通过代码库进行grepping。 ASP surrounds its own code in tags (like JSP), so the javascript (or at least things other than specific element names) should be contiguous. ASP将自己的代码括在标记中(例如JSP),因此javascript(或至少除特定元素名称之外的其他内容)应该是连续的。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM