Note that there are some explanatory texts on larger screens.

plurals
  1. POWhy would an iframe's history get added to the history
    primarykey
    data
    text
    <p>In jQuery mobile I am using an iframe. When you press the back button (in the app or the browsers back button) the iframe content goes away. Then when you press the back button again the app transitions to the previous page.</p> <p>The iFrame is getting added to history. I thought this was never supposed to happen.</p> <p>A <a href="http://jsfiddle.net/kolban/6achL3ez/" rel="nofollow">jsFiddle</a> has been created that illustrates the puzzle in as simple a form as possible.</p> <p>In it you will find a fragment of HTML that creates two jQuery Mobile pages. On the first page there is a link to go to the second page. On the second page,there are two back buttons (one on the header and one as a button on the page) and also a button to reload the <code>&lt;iframe&gt;</code>. To recreate the problem:</p> <ul> <li>From page 1 follow the link to page 2</li> <li>On page 2, click the button to load the <code>&lt;iframe&gt;</code></li> <li>Click either of the back buttons</li> </ul> <p>You will notice that you do <strong>not</strong> go back to page 1.</p> <p>Here is the HTML:</p> <pre><code>&lt;div data-role="page"&gt; &lt;p&gt;This is page 1&lt;/p&gt; &lt;a href="#page2"&gt;Go to page 2&lt;/a&gt; &lt;/div&gt; &lt;div data-role="page" id="page2"&gt; &lt;div data-role="header" data-add-back-btn="true"&gt; &lt;h1&gt;Page 2&lt;/h1&gt; &lt;/div&gt; &lt;p&gt;This is page 2&lt;/p&gt; &lt;p&gt;What follows is the iFrame&lt;/p&gt; &lt;iframe id="i1" width="500" src="http://www.ibm.com"&gt;&lt;/iframe&gt; &lt;p&gt;This button issues a programmatic back&lt;/p&gt; &lt;button id="backButton"&gt;Go Back&lt;/button&gt; &lt;p&gt;This button loads new content into the iframe&lt;/p&gt; &lt;button id="reloadButton"&gt;Reload iFrame&lt;/button&gt; &lt;/div&gt; </code></pre> <p>Here is the JavaScript</p> <pre><code>$(function () { $("#backButton").click(function () { jQuery.mobile.back(); }); $("#reloadButton").click(function() { $("#i1").attr("src", "http://www.microsoft.com?x=" + Math.random()); }); }); </code></pre> <p>(This is the code you will find in the jsFiddle).</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.
    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