Welcome Guest, Not a member yet? Register   Sign In
named anchor browser problem
#1

[eluser]jupiter1031[/eluser]
<body>

this is part of a CI project and I am trying to jump to the original location and not to the top of the overview when I return from a detail screen.
I am getting desperate trying many variations of this but until now this only works in Chrome and not in IE or Firefox. I also tried <body>
I tried to put it in a function, but the result is always the same.

Has anybody an idea how to make this browser independent?
#2

[eluser]pickupman[/eluser]
How about posting some code of what you are trying? Maybe you are trying to manipulate the default behavior of a browser which may not be possible.

If I were to try and guess what you are doing, I would say that if a user scrolls down so far below the first fold, click a link, goes to the next page, then click back, you want them to see the page where they last clicked.

If that is the scenario, and you are not having any luck across browser, you could achieve this using javascript. You would have to create a click handler attached to all anchor elements. In your click handler, you would have to get the browser/window position, save it to a cookie. Create another onload event that would check for the position saved and the cookie, and move the screen to that offset.

Again, browsers will usually do this for you unless certain content headers are sent to prevent it.
#3

[eluser]jupiter1031[/eluser]
Thank you for your reply despite my cryptic message. The forum did remove the code I had posted.
Let me try putting it in again

&lt;body onload= window . location . hash session->userdata('hash')."'"?&gt;"> // this translates into #a13 or any number. the actual anchor to jump to is <a name="a13"></a>

PS: this is not a copy of the code, be assured the original is syntactically correct, this should just give you the idea of my intend. Again it works great only in Chrome so far.

The javascript code gets mutilaltd here. I am using [removed].href #URL to jump to the location.

I have enclosed a file to illustrate what I have. pay attention to line 67 that generates the anchor. and of course the body tag.
#4

[eluser]InsiteFX[/eluser]
To link to a specific spot on a web page, you need to use a pair of anchors. One where you are linking from, and one where you would like to link to. The first one, is where you are linking from. It is very similar to the normal link tag. The starting tag looks like <A HREF="#name"> and the closing tag looks like </A>. The text between the two tags is what is the link. The text "name" identifies the anchor, giving it a name.
The second anchor identifies where you are linking to. This tag must be placed in your HTML in the location where you would like to link to. The starting tag is <A NAME="name"> and the closing tag is </A>. It is not necessary that any text goes between these two tags as it is just identifying an area. The text "name", must match that in the first anchor, for the link to work. Here is an example of an internal link.

Code:
&lt;BODY&gt;

<A NAME="top"> </A>

<A HREF="#top"> Go To Top Of Page </A>

&lt;/BODY&gt;

InsiteFX
#5

[eluser]pickupman[/eluser]
It looks like your code is how InsiteFX posted. You should just make sure that you are capturing the hash when leaving the page.
#6

[eluser]jupiter1031[/eluser]
It is. The problem is that everything seems correct, Chrome does what I expected, Firefox and IE don't. All that happens is they move the screen a little down but don't jump to the anchor. It must be a javascript issue with the question when the code runs, before or after the page is finished loading. But that is just a guess. I have tried many variations but so far I have not found the solution. It is beyond my limited understanding of the inner works of HTML.




Theme © iAndrew 2016 - Forum software by © MyBB