By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
435,197 Members | 1,207 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 435,197 IT Pros & Developers. It's quick & easy.

Reposition on a linked page with no anchor?

P: n/a
I'm trying to create a link to a certain part of a page on another
website that has
no anchor (i.e. ID or name) at the position on the page I want to link
to. So I can't do something like theotherpage.html#anchorname.
However, since there is a unique keyword at the position I want to link
to I thought perhaps I could load the page, then search for this
keyword and then reposition to that point. Can javascript do something
like this?

Thanks

Dec 29 '05 #1
Share this Question
Share on Google+
5 Replies


P: n/a
http://msdn.microsoft.com/library/de...llintoview.asp

object.scrollIntoView(). Might be an IE only thing. I don't know how
you could run a script on another page though.

Dec 29 '05 #2

P: n/a
http://msdn.microsoft.com/library/de...llintoview.asp

object.scrollIntoView(). Might be an IE only thing. I don't know how
you could run a script on another page though.

Dec 29 '05 #3

P: n/a
On 2005-12-29, ukrbend <uk******@yahoo.com> wrote:
I'm trying to create a link to a certain part of a page on another
website that has
no anchor (i.e. ID or name) at the position on the page I want to link
to. So I can't do something like theotherpage.html#anchorname.
However, since there is a unique keyword at the position I want to link
to I thought perhaps I could load the page, then search for this
keyword and then reposition to that point. Can javascript do something
like this?


probably. but in most cases it'd be much easier to put the <a>nchor into the
document.

you won't be able to scroll the document if it's from a different server
unless you can get your javascript included on the other server....
anyway to do what you're asking.

Traverse the DOM tree looking for the text you want and then figure out the
coordinates of the item you're chasing. and scroll to that.

sounds simple? AIUI calculating the screen location of an element can be
tricky.
It may be easier to make an anchor and insert it before the text. and then
update location.hash to refer to it.

Bye.
Jasen
Dec 30 '05 #4

P: n/a
Ivo
"ukrbend" wrote
I'm trying to create a link to a certain part of a page on another
website that has
no anchor (i.e. ID or name) at the position on the page I want to link
to. So I can't do something like theotherpage.html#anchorname.
However, since there is a unique keyword at the position I want to link
to I thought perhaps I could load the page, then search for this
keyword and then reposition to that point. Can javascript do something
like this?


Yes, this is a common task for Javascript, but like anything Javascript, it
will only work within one website. Cross-domain restrictions (google for
that) prohibit script from your site to access scroll positions or anything
on the other site. All I think of for this situation is you write to the
other webmaster and ask for that anchor to be put there.

hth
ivo
http://www.lear.shakespearians.com/
Dec 30 '05 #5

P: n/a
ukrbend wrote:
I'm trying to create a link to a certain part of a page on another
website that has no anchor (i.e. ID or name) at the position on the
page I want to link to. So I can't do something like
theotherpage.html#anchorname. However, since there is a unique
keyword at the position I want to link to I thought perhaps I could
load the page, then search for this keyword and then reposition to
that point. Can javascript do something like this?


No. scrollIntoView(), which is also proprietary to the IE DOM,
will not work when the target document is not already displayed.
PointedEars
Dec 30 '05 #6

This discussion thread is closed

Replies have been disabled for this discussion.