Link that scrolls to position

10,204

Solution 1

I don't have control of the linked page

All you can do is link to an anchor/ID on the page. If the first block of text on the targeted page has an ID attribute, then you can link to that:

wwww.example.com/page.html#blockOfTextID

Solution 2

No, you can only link to parts of the page that already have named anchors on the page.

Link that scrolls to position

Which links to my answer to your question. But only works, because Stack Overflow has HTML like:

<a name="7324427"></a>

Above every answer to make this possible.

Share:
10,204
James
Author by

James

Updated on August 02, 2022

Comments

  • James
    James almost 2 years

    Is it possible to create a link to any web page and scroll to the position of the first instance of a block of text?

    eg:

    http://techcrunch.com/2011/09/06/google-api-launch-still-months-away/#scrollto"A Google project headed by Vic Gundotra"
    

    and this will scroll to some where half way of the page.

    Note: I don't have control over the linked page, it could be any page on the web. Is there any javascript trick that will allow me to do what I described?

  • James
    James over 12 years
    Is there any javascript trick that will allow me to do what I described?
  • James
    James over 12 years
    I already know this. thanks anyway. the problem is I don't have control over the linked page (it could be any page on the web)
  • DA.
    DA. over 12 years
    Right. Well, that's all you can do.
  • DA.
    DA. over 12 years
    It's not your page. Therefore, you can't run any JS on it.
  • James
    James over 12 years
    what about putting it into an iframe and scroll that? is it possible?