PDA

View Full Version : Anchor tags bringing me down. Need assistance on tricky call.


zoliff
10-08-2002, 06:50 AM
I have page one (p1) which has various links to page 2 (p2), and it needs to link to specific anchor tags on the p2. Problem is that I can't do the typical anchor tag call in the URL and place a simple #anchor_area at the end of the URL because of the types of calls I am making.

I was trying to come up with a way in which the javascript on p2 would look for a certain text in the incoming XML from p1 and basically load the browser viewing area in the anchored area. I currently have anchor tags on p2 but I can't figure out what to do with them (Javascript wise).

I was thinking about trying to scrollTo() certain areas of the page depending on what is returned, but I can't find any detailed information about anchor tags and how to jump to specific anchors on the page.

Any help/ideas would be greatly apprecited. Trying to come up with some javascript which would accept a certain anchor tag as its input, and basically set the focus on that certain anchor tag on the page.

Getting extremely frustrated at these wonderful tags :mad:

Thanks again

glenngv
10-08-2002, 06:58 AM
what do you mean by this:

"Problem is that I can't do the typical anchor tag call in the URL and place a simple #anchor_area at the end of the URL because of the types of calls I am making."

zoliff
10-08-2002, 05:40 PM
I am making an ISAPI call and the way that I post the URL it does not allow me to add a simple #anchor_tag at the end of the URL.

Any ideas on how to do this with javascript?

glenngv
10-09-2002, 02:09 AM
i still can't get what you mean. can post some code?

hismightiness
08-03-2005, 08:52 PM
I know this is several years down the road, but I thought this information would be useful to others who may happen across this thread.

I found a solution by using a JavaScript function from Matt Kruse and putting it to use with a bit of my own. The link to his source is here:

http://www.mattkruse.com/javascript/anchorposition/

Then in my HTML I have an anchor in there like so:

<a id="ancRelated" name="ancRelated">&nbsp;</a>
I then added a bit of my own JavaScript like so:

<script language="javascript" type="text/javascript">
function ScrollToRelated(){
// ancRelated is the anchor name
var pos;
pos = getAnchorPosition('ancRelated');
self.scrollTo(pos.x, pos.y);
}
</script>
The function I use of his is "getAnchorPosition". I call this and it returns an object which contains the xy coordinates of the anchor and I can then use the scrollTo function to make the web page seemingly "focus" on the anchor. However, it does not actually focus on it in the sense that we would think of focusing on a form field.