views:

51

answers:

3

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 to 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.

+2  A: 

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.

womp
Wow, that gives me a good a start. Thanks for the help.
McVillain
Vilx-
Just a random question -- what's the advantage of compiling the JS into an embedded resource? Personally I think its poor practice... opinions?
Plan B
A: 

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?

Plan B
I tried adding that to the bottom of the defualt.aspx file with no results. It doesn't show up in the page source.
McVillain
A: 

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.

abc