James
James

Reputation: 235

Link that scrolls to position

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?

Upvotes: 5

Views: 16668

Answers (4)

ledlightjungled
ledlightjungled

Reputation: 43

Two lines with two possible outcomes.
First the assumption:solution

wwww.example.com/page.html#blockOfTextID

DA.

If the conclusion is ("), yes, I do know what the syntax could be. You can try. . .

https://docs.github.com/en/pages/setting-up-a-github-pages-site-with-jekyll/testing-your-github-pages-site-locally-with-jekyll#building-your-site-locally

A second outcome you can get also through a
solution:assumption line which may be, ("), i have tried but i am not able to compare

https://docs.github.com/en/pages/setting-up-a-github-pages-site-with-jekyll/testing-your-github-pages-site-locally-with-jekyll#building-your-site-locallyID

Upvotes: 0

NaN
NaN

Reputation: 86

Yes, what you're looking for is a Text Fragment:

Text Fragments

I know this is an old question, but the answers pre-date this technology, and I was researching a similar issue and noticed this came up as a top result.

Upvotes: 1

DA.
DA.

Reputation: 40697

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

Upvotes: 4

Paul
Paul

Reputation: 141917

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.

Upvotes: 2

Related Questions