[eluser]jupiter1031[/eluser]
I have a long page with a list of projects. After I go to a detail page I would like to return to the same project in the overview page and not on top of the page.
So with difficulties and with a combination of PHP and javascript I built a named anchor solution. This solution works in Chrome only but not in Firefox and IE.
Here are the code parts that make it work:
1) From single page go back to overview, I keep the anchor information in a cookie
Code:
<?php foreach ($records as $row) : ?>
<a href="<?php echo site_url('ge/projects_eng' )?>">PROJECTS OVERVIEW</a> |
<?php $this->session->set_userdata('hash',"a".$row->prj_index); ?>
<?php break ?>
<?php endforeach ?>
2)
I overview I have a simple javascript that onload jumps to the named anchor on the page
Code:
function moveWindow()
{
window . location . hash="<?php echo $this->session->userdata('hash')?>";
}
// this will create a variable "a13" for example
</head>
< body> /* Your editor removed the onload part code - here I just have a simple body onload moveWindow() */
3)
The anchor looks like this:
Why does this work only in one browser?
But my actual question is how do I get this to work in any browser?
Any other solutions I have not thought of?
Again what I really want is to come back to the place in my list from where I started.