0

I need to link to a specific div tag with an id on another website, of which I have no control over the content. I can do this easily enough using the #, i.e. http://url.com/#content. But unfortunately, I need the browser frame to be offset to 180 pixels above the anchor tag.

Is there any way to do this only through the URL? Is it possible to pass a jQuery variable (they use jQuery in the site) through the URL, such as window.location or .offset?

user1997781
  • 1,913
  • 2
  • 14
  • 17
  • 2
    not unless you control the other site. You can't inject/ execute javascript on a third party site – helion3 Feb 19 '14 at 18:50

1 Answers1

0

Use offset().top and load this script on load while you navigate to your other page..

 $('html, body').animate({
       scrollTop: $('#content').offset().top -180 + "px"
    }, 1500);
Aditya
  • 4,453
  • 3
  • 28
  • 39
  • How would I load this script when linking to someone else's site, though? – user1997781 Feb 19 '14 at 19:00
  • You can find this thread useful : http://stackoverflow.com/questions/2303147/injecting-js-functions-into-the-page-from-a-greasemonkey-script-on-chrome – Aditya Feb 19 '14 at 19:02
  • Forgive me if I'm just not understanding, but I still don't see how I can link to someone else's page (where I can't edit the content or load a script) and jump to a certain point using these methods? It seems like every answer requires that JavaScript be loaded on the destination page, and I can only load it on the launch page. I also don't have the luxury of using an iFrame. – user1997781 Feb 19 '14 at 20:17