Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 264295
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 11, 20262026-05-11T22:40:25+00:00 2026-05-11T22:40:25+00:00

location.hash seems to be utterly broken in Safari 4: It can be set initially,

  • 0

location.hash seems to be utterly broken in Safari 4: It can be set initially, but cannot be set in any event as far as I can tell, whether that event is triggered by a user action or a timer.

Here’s an example (I use jQuery here for brevity, but I can’t imagine that this problem is jQuery-specific):

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" lang="en" xml:lang="en">
    <head>
        <!-- Include jQuery -->
    </head>
    <body>
        <div id="test">Click the link below to make this text bold.</div>
        <p><a href="#test">Bold it!</a></p>
        <p id="hashValue"></p>
        <script>
$(document).ready(function() {
    location.hash = '#normal';          // this works in all browsers
    $('a').click(function() {
        $('#test').css({'font-weight': 'bold'});
        location.hash = '#bold';        // this fails in Safari 4
        return false;   // prevents link href from affecting hash
    });
    setInterval(function() {
        if (! location.hash.match('bold$')) {
            $('#test').css({'font-weight': 'normal'});
        }
        $('#hashValue').html(location.hash);
    }, 100);
});
        </script>
    </body>
</html>

In Firefox, the behavior is what you’d expect: When you load the page, the hash is set to #normal. When you click the link, the text becomes bold and the hash is set to #bold. Because the hash has been changed, the interval function has no effect. If you change the hash in the address bar to something else (that doesn’t end in bold), the text gets un-bolded. This lets the back button work intuitively: Click back to where the hash is #bold, and the text becomes bold. Click to anywhere else, and the text is un-bolded.

But in Safari 4, the behavior is: When you load the page, the hash is set to #normal. And then it will stay that way forever, as far as the address bar is concerned. When you click the link, the text will become bold, and will stay that way, even though the hash in the address bar hasn’t changed. So, location.hash is changed internally (as the hashValue paragraph reflects). This inconsistency with the address bar has dire consequences: If you click the back button, the text is un-bolded; but if you click the forward button after that, it doesn’t get re-bolded! This totally breaks JavaScript history libraries, such as the jQuery history plugin.

Any fixes? Any workarounds? I tested this in Safari 4.0.1 on a Mac.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-11T22:40:25+00:00Added an answer on May 11, 2026 at 10:40 pm

    It turns out that this wasn’t a bug in Safari at all, but rather in Glims, a plug-in I was using:
    Link

    Removing the plugin fixed the problem. I didn’t consider this as a possibility because I have no idea why Glims would mess with JavaScript’s interaction with the address bar.

    Reinstalling the latest build, it seems not to suffer from this problem.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I know on client side (javascript) you can use windows.location.hash but could not find
I have this simple script: $(document).ready(function(){ var $yoyo = window.location.hash; alert($yoyo); }); But I
I want to refresh with new hash but it seems chrome just changes the
can someone please help with the window.location.hash and the .cycle script. I've been trying
The goal: Correctly put a string from a data attribute into the window.location.hash .
After removing hash from URL using window.location.hash='' page getting reloaded in firefox. EDIT Example:
The location text from Twitter could be just about anything. Sometimes Twitter clients set
Here's some simple Javascript: (function($){ var ajax_callback = function(data) { window.location.hash = data.h1; };
i'm having trouble with modifying the location hash in IE8 for XP. simply calling:
I've noticed some strange behaviour in JS window.location.hash = ''; var hash = window.location.hash;

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.