Note that there are some explanatory texts on larger screens.

plurals
  1. POIs there a standard way of defining the href that opens in a document.open call?
    primarykey
    data
    text
    <p>The dilemma that I'm dealing with is that in the <a href="https://raw.github.com/cowboy/jquery-bbq/v1.2.1/jquery.ba-bbq.js" rel="nofollow">jquery-bbq code</a>, because IE6 and IE7 do not support <code>hashchange</code>, they load pages twice in order to have a history state.</p> <p>This has a negative effect because code runs twice on both server-side and client-side. The method used to create the iframe is this:</p> <pre><code> if ( is_old_ie ) { // Create hidden IFRAME at the end of the body. iframe = $('&lt;iframe src="javascript:0"/&gt;').hide().appendTo( 'body' )[0].contentWindow; // Get history by looking at the hidden IFRAME's location.hash. get_history = function() { return get_fragment( iframe.document.location.href ); }; // Set a new history item by opening and then closing the IFRAME // document, *then* setting its location.hash. set_history = function( hash, history_hash ) { if ( hash !== history_hash ) { var doc = iframe.document; doc.open().close(); doc.location.hash = '#' + hash; } }; // Set initial history. set_history( get_fragment() ); } </code></pre> <p>A blank iframe with a src of <code>javascript:0</code> is created. The <code>document.open</code> method is called, and it seems like it grabs the <code>location.href</code> of the parent window as the default for the page that opens with <code>.open</code>.</p> <p>I basically have to modify the code so that it doesn't open the same url twice, so I'm looking to override the default and specify a param such as ?iframe=true.</p> <p>Example:</p> <p><a href="http://example.com/views/step-2?one=two" rel="nofollow">http://example.com/views/step-2?one=two</a></p> <p>In IE, the page above gets loaded and then gets loaded again in an iframe. The server-side code executes <strong>twice</strong>, but I don't want that to happen.</p> <p>I want to append <code>&amp;iframe=1</code> to the URI so I can prevent my server-side code from running if the <code>iframe</code> param is specified.</p> <p>The two most obvious things are:</p> <ol> <li>Set the src of the iframe, but this could have a negative effect and I'm pretty sure it's there for a reason.</li> <li>Instead of use <code>document.open.close</code>, use <code>iframe.location.href</code> and set it to the href manually.</li> </ol> <p>If anyone has had experience with iframe hacking, I'd greatly appreciate some tips.</p> <p><strong>EDIT</strong>: Another workaround I thought of would be loading a page through iframe/ajax that sets a session var before the iframe does the <code>document.open</code>, which creates a session variable of 'iframeloading' which is equal to 1, and set a load event handler on iframe load to set it back to 0, and adjust my server-side code to not execute if the session var is set to 1. Something like:</p> <pre><code>$('&lt;iframe src="/iframe-loading.php"/&gt;').hide().appendTo('body'); document.open().close() $( document.defaultView ).load(function() { $('&lt;iframe src="iframe-doneloading.php/&gt;').hide().appendTo('body'); }); </code></pre>
    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.
 

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