Getting URL of executing JavaScript file (IE6-7 problem mostly)

前端 未结 2 1966
爱一瞬间的悲伤
爱一瞬间的悲伤 2020-12-15 19:27

Hey all, I\'ve been trying to throw together a generic function that retrieves the absolute URL of an executing JavaScript file on a web page:

http://gist.github.com

2条回答
  •  独厮守ぢ
    2020-12-15 19:52

    A lot of this depends on what you have access to. If, as it appears, you are trying to do this entirely within the JS code, I do not believe that you are able to do it, for some of the reasons shown above. You could get 90% of the way maybe, but not be definitive.

    If you are working in a dotnet environment ( which is the only one I know ), I would suggest the use of a module that would intercept all JS requests and add into them the request location, or something of that nature.

    I think you need to address this from the server side, not the client side. I do not think you will have a definitive answer form the client side. I think you will also struggle to get an answer from the server side, but you might be more successfull.

提交回复
热议问题