Note that there are some explanatory texts on larger screens.

plurals
  1. POIs it possible to alter one frame from another using Javascript?
    primarykey
    data
    text
    <p>OK, there have been a lot of discussions on this topic, but I haven't quite found an answer (see <a href="https://stackoverflow.com/questions/5660116/unsafe-javascript-attempt-to-access-frame-in-google-chrome">Unsafe JavaScript attempt to access frame in Google Chrome</a>, <a href="https://stackoverflow.com/questions/4324108/unsafe-javascript-attempt-to-access-frame-with-url">Unsafe JavaScript attempt to access frame with URL</a> for example).</p> <p>Here's my situation:</p> <p>I've got a file called index.html that looks like this:</p> <pre><code>&lt;frameset&gt; &lt;frame src="a"&gt; &lt;frame src="b"&gt; &lt;/frameset&gt; </code></pre> <p>Then 'a' looks like this:</p> <pre><code>&lt;script language='javascript'&gt;document.domain = document.domain&lt;/script&gt; &lt;img src='whatever.jpg' id='foo'/&gt; </code></pre> <p>And 'b' looks like this:</p> <pre><code>&lt;script language='javascript'&gt; &lt;!-- setTimeout(function() { document.domain=document.domain document.write('top domain is ' + document.domain) document.domain = document.domain top.a.document.images['foo'].src = 'something.jpg' }, (5 * 1000)); //--&gt; &lt;/script&gt; </code></pre> <p>So in a nutshell: a is a frame with a single image in it. b is a frame that should automatically change the src attribute of a's image link. But Chrome is unhappy!</p> <p>(Note that I added the "document.domain=document.domain" lines pursuant to comments below).</p> <p>(Also, note that the 5 second delay in frame 'b' is necessary to get a valid-looking URL for the call.)</p> <p>According to the Chrome js debugger, this is causing a "unsafe javascript attempt to access url". Based on the other discussions of this error on Stack Overflow, it's unclear to me if there are any conditions under which I'm allowed to do this. These files (index, a, b) are entirely local on my machine. So there shouldn't be any concerns about them coming from different domains.</p> <p>Any ideas? Sorry for re-posting, but I've quite found a definitive answer...</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.
 

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