i'm designing a website with a gallery whose images contain anchors and records the location whenever a picture is viewed for example if the current picture is #pic1 then the url would be www.website.com/gallery/album1#pic1 , if i click on pic7 the url would be www.website.com/gallery/album1#pic7 and so on.. i did this so that when the url is copied and pasted the gallery would still show the last viewed image. my problem now is when i click back in my browser, the browser goes back to the previous picture not to the album, like if in the previous example if im still at pic7 the back button will take me to www.website.com/gallery/album1#pic1 instead of www.website.com/gallery
so my question is how can i program the browser back button to go back to the gallery immediately?
this is what i tried but it isnt working..
Expand|Select|Wrap|Line Numbers
- <html>
- <head>
- <script type="text/javascript">
- function backToGallery()
- {
- if(window.history.previous)
- {window.location.href='gallery.html';}
- }
- </script>
- </head>
- <body onunload="backToGallery()">
- </body>
- </html>