Set location. Hash to something else first and immediately set it back.
Up vote 0 down vote favorite share g+ share fb share tw.
I can't get window.location. Hash = location. Hash to work in Safari.
I'm using javascript to wrap the contents of my page with a scrollable DIV, placed below the navigation bar in my webpage. Since the scrollbar's location gets reset when the javascript runs, I'm losing the original hash location that the URL set. I need to re-cue the hash location without reloading the page using javascript, so I'm using window.location.
Hash = location.hash. It works in IE8, Firefox, and Opera, but it doesn't work in Safari. (I'll assume Chrome, too, but I haven't check).
Any suggestions? Hint: I like jQuery. Javascript google-chrome safari webkit link|improve this question edited Aug 7 '11 at 20:15 asked Aug 7 '11 at 4:37Brandon Lebedev1088 86% accept rate.
Define "doesn't work", please. – Lightness Races in Orbit Aug 7 '11 at 4:39 @Tomalak As far as I can tell, that line of code never executes in Safari. (1) The wrapper javascript executes, resetting the scrollbar location to the top of the page.
(2) An alert appears, telling me the window...hash function is the next thing to run on the page... and that's it. Nothing else (pertinent) happens. – Brandon Lebedev Aug 7 '11 at 4:50.
Set location. Hash to something else first and immediately set it back. Var t = window.location.
Hash; window.location. Hash = "non-existant-id"; window.location. Hash = t.
No cigar. Your code only modified the URL hash tag. It never moved the page.
– Brandon Lebedev Aug 7 '11 at 4:55.
Before JavaScript changes the orginal hash location, get the scroll position using var st = $(window).scrollTop(). When you want to restore the scroll location, use $(window). ScrollTop(st).
Var st = $(window).scrollTop() doesn't even set the variable in Safari. When I run $(window). ScrollTop(st), the console gives me a variable undefined error.
(The code works in other browsers, though. ) – Brandon Lebedev Aug 7 '11 at 19:37.
Webkit has two oddities that prevent window.location. Hash = location. Hash from working normally.
Webkit responds to window.location. Href instead of window.location. Hash (like all the other browsers do).
Curiously, webkit can still read the URL's hash tag using location. Hash Webkit has a documented bug where the href location has to be set to the same location twice before the browser will go to the new location. Bug report here.
This code solved my problem: (using jQuery). $(document). Ready(function() { gotoHASH() }; function gotoHASH() { if (location.
Hash) { if ( $.browser. Webkit == false ) { window.location. Hash = location.
Hash } else { window.location. Href = location. Hash; window.location.
Href = location. Hash } } }.
I have a answer for this on this page code here.
Your answer has nothing to do with setting the hash in Webkit. – Brandon Lebedev Oct 4 '11 at 2:02.
I cant really gove you an answer,but what I can give you is a way to a solution, that is you have to find the anglde that you relate to or peaks your interest. A good paper is one that people get drawn into because it reaches them ln some way.As for me WW11 to me, I think of the holocaust and the effect it had on the survivors, their families and those who stood by and did nothing until it was too late.