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 5844079
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 22, 20262026-05-22T12:14:36+00:00 2026-05-22T12:14:36+00:00

In Safari, if there’s an iframe loading, and the user changes the history state

  • 0

In Safari, if there’s an iframe loading, and the user changes the history state by going back or forward, the popstate event isn’t triggered, causing the application state and the window location to be out of sync.

I think that an active XHR request will cause the same behavior, but I haven’t been able to confirm that yet.

Here’s a jsfiddle that will allow you to easily reproduce the issue:
http://jsfiddle.net/neonsilk/muHk8/

You just have to click the links/buttons in order, from 1 to 6.

In Safari 5.0.5, the output is:

(reverse chronological, the important part is the state comparison at the top)

[1305665493096] /
[1305665493096] vs
[1305665493096] /node
---------------
[1305665489955] iframe loaded
---------------
[1305665489806] (did popstate or $.address change trigger?)
[1305665489805] called history.back()
[1305665489805] appended iframe
---------------
[1305665488428] popstate: /node
[1305665488427] $.address change: /node
---------------
[1305665487821] popstate: /
[1305665487821] $.address change: /
---------------
[1305665487179] $.address change: /node
---------------
[1305665486606] $.address change: /
---------------
[1305665485732] iframe loaded
---------------
[1305665485569] $.address change: /neonsilk/muHk8/show/
[1305665485568] $.address init

Yet in Chrome (11) or FireFox (4.0), the output looks like:

(note that the states are in sync)

[1305665609499] /
[1305665609499] vs
[1305665609499] /
---------------
[1305665608360] iframe loaded
---------------
[1305665607770] popstate: /
[1305665607770] $.address change: /
[1305665607758] (did popstate or $.address change trigger?)
[1305665607758] called history.back()
[1305665607758] appended iframe
---------------
[1305665606870] popstate: /node
[1305665606869] $.address change: /node
---------------
[1305665606150] popstate: /
[1305665606149] $.address change: /
---------------
[1305665605551] $.address change: /node
---------------
[1305665604808] $.address change: /
---------------
[1305665603354] iframe loaded
---------------
[1305665602688] $.address change: /neonsilk/muHk8/show/
[1305665602682] $.address init
[1305665602676] popstate: /neonsilk/muHk8/show/

Is this a bug in Safari? And if it is, has anyone discovered a workaround?

(It’s also interesting that both FireFox and Chrome fire a popstate event on page load.)

  • 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-22T12:14:36+00:00Added an answer on May 22, 2026 at 12:14 pm

    Update

    This bug was, as far as I can tell, first reported by Ben Cherry.

    Here is the corresponding bug report and changeset from WebKit.

    And the issue from Chromium.

    I haven’t been able to figure out when the bug was fixed in Chrome. If anyone else has, I would greatly appreciate the info.

    I do know that the bug exists in WebKit 533.21.1 (which is what Safari 5.0.5 uses), and has been fixed by 534.36 (Safari/WebKit nightly) — but I don’t know, and haven’t been able to figure out, which intermediary build introduced the fix.

    There is a helpful chart that maps the Chrome version to its WebKit version.

    Most importantly, this bug apprently occurs when there is any active network traffic (images loading, Ajax requests, etc.), and not just iframes. If you are trying to implement History API support, or you are using the latest version of Asual’s jQuery Address plugin (which has history support enabled by default), this bug could seriously impact your application.


    2nd Update

    I think I tracked down the exact WebKit version where the fix was introduced (534.10). So, if you are using jQuery and Asual’s Address plugin, here’s the practical solution:

    if (!($.browser.webkit === true && parseFloat($.browser.version) < 534.10)) {
        // only enable state support if WebKit version >= 534.10
        $.address.state("/base/path");
    }
    

    I hope this helps someone!


    I just tested the fiddle in the latest WebKit nightly (r86671), and the state stays in sync, so it must be a bug. Funny how spending a lot of time writing up a question and submitting it immediately inspires the answer.

    Still, if anyone has a workaround, it would be greatly appreciated.

    WebKit nightly (r86671):

    [1305666598481] /
    [1305666598481] vs
    [1305666598480] /
    ---------------
    [1305666597469] iframe loaded
    ---------------
    [1305666597300] popstate: /
    [1305666597298] $.address change: /
    [1305666597270] (did popstate or $.address change trigger?)
    [1305666597269] called history.back()
    [1305666597269] appended iframe
    ---------------
    [1305666596605] popstate: /node
    [1305666596605] $.address change: /node
    ---------------
    [1305666596008] popstate: /
    [1305666596008] $.address change: /
    ---------------
    [1305666595555] $.address change: /node
    ---------------
    [1305666595142] $.address change: /
    ---------------
    [1305666578600] iframe loaded
    ---------------
    [1305666578400] $.address change: /_display/
    [1305666578400] $.address init
    ---------------
    [1305666577964] popstate: /_display/
    

    Also interesting that Safari now matches the behavior of Chrome and FireFox, firing popstate on page load.

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

Sidebar

Related Questions

Is there any way to spoof the user agent on Safari on the iPhone?
Is there any way to access History of iPhone Safari? Regards, krishnan
EVENT.DEACTIVATE doesn't work with safari in mac, is there any possible way to do
In safari's (and chrome's) element inspector there's an Event Listeners section (in the right
Is there an alternative to history.go(-1) for FireFox and Safari. Any Help would be
Is there now a length limit or other changes to how Safari 5 uses
I am wondering if there is some way to replicate Safari (on the iPhone's)
I am making an application that involves controlling Safari from Applescript. Is there a
I have implemented the plugin by NPAPI for Firefox, Chrome, Safari, but there is
With Safari you can disable most iframe scrolling by setting style=overflow: hidden; on the

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.