Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>I did some tests in Firefox 3 comparing the value of <code>.src</code> and <code>.documentWindow.location.href</code> in an <code>iframe</code>. (Note: The <code>documentWindow</code> is called <code>contentDocument</code> in Chrome, so instead of <code>.documentWindow.location.href</code> in Chrome it will be <code>.contentDocument.location.href</code>.)</p> <p><code>src</code> is always the last URL that was loaded in the iframe without user interaction. I.e., it contains the first value for the URL, or the last value you set up with Javascript from the containing window doing:</p> <pre><code>document.getElementById("myiframe").src = 'http://www.google.com/'; </code></pre> <p>If the user navigates inside the iframe, you can't anymore access the value of the URL using src. In the previous example, if the user goes away from www.google.com and you do:</p> <pre><code>alert(document.getElementById("myiframe").src); </code></pre> <p>You will still get "<a href="http://www.google.com" rel="noreferrer">http://www.google.com</a>".</p> <p><code>documentWindow.location.href</code> is only available if the iframe contains a page in the same domain as the containing window, but if it's available it always contains the right value for the URL, even if the user navigates in the iframe.</p> <p>If you try to access <code>documentWindow.location.href</code> (or anything under <code>documentWindow</code>) and the iframe is in a page that doesn't belong to the domain of the containing window, it will raise an exception:</p> <pre><code>document.getElementById("myiframe").src = 'http://www.google.com/'; alert(document.getElementById("myiframe").documentWindow.location.href); Error: Permission denied to get property Location.href </code></pre> <p>I have not tested any other browser.</p> <p>Hope it helps!</p>
    singulars
    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. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      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