Note that there are some explanatory texts on larger screens.

plurals
  1. POWhy isn't popstate triggered in Safari when an iframe is loading?
    primarykey
    data
    text
    <p>In Safari, if there's an <code>iframe</code> loading, and the user changes the history state by going back or forward, the <code>popstate</code> event isn't triggered, causing the application state and the window location to be out of sync.</p> <p>I think that an active XHR request will cause the same behavior, but I haven't been able to confirm that yet.</p> <p>Here's a jsfiddle that will allow you to easily reproduce the issue: <a href="http://jsfiddle.net/neonsilk/muHk8/" rel="nofollow">http://jsfiddle.net/neonsilk/muHk8/</a></p> <p>You just have to click the links/buttons in order, from 1 to 6.</p> <p>In Safari 5.0.5, the output is:</p> <p>(reverse chronological, the important part is the state comparison at the top)</p> <pre><code>[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 </code></pre> <p>Yet in Chrome (11) or FireFox (4.0), the output looks like:</p> <p>(note that the states are in sync)</p> <pre><code>[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/ </code></pre> <p>Is this a bug in Safari? And if it is, has anyone discovered a workaround?</p> <p>(It's also interesting that both FireFox and Chrome fire a <code>popstate</code> event on page load.)</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload