How to call JavaScript function from one frame to another in Chrome / Webkit with file protocol

I developed an application that has a list of elements in a single frame; when one click on an element does something in another frame (loads an image).

This works well in all browsers, including Chrome 3; now it still works fine in Firefox, but in the latest versions of Chrome (I believe that since 4) it causes this error:

Unsafe JavaScript is trying to access a frame with a URL (...) from a frame with a URL (...). Domains, protocols, and ports must be consistent.

This is obviously a security feature, but is it possible to get around this?

Here is a simple test:

index.html

<html>
  <frameset cols="50%,50%">
    <frame src="left.html" name="left"/>
    <frame src="right.html" name="right"/>
    </frameset>
  </html>

left.html:

<html>
  <body>
    <a href="javascript:parent.right.test('hello');">click me</a>
    </body>
  </html>

right.html:

<html>
  <body>
    <script>
      function test(msg) {
        alert(msg);
        }
      </script>
    </body>
  </html>

This works in Firefox 3.6 and Chrome 3, but in Chrome 5 it throws the above error ...

Edit

  • @cols attribute added to frameset element
  • Chrome , http ( ), , ://protocol. Firefox ( ) Chrome 3, Chrome 5 ( Chrome 4, ( , Chrome?) - Chrome 5 , ).
+2
2

. : JavaScript, iframe Chrome, .

, Chrome --allow-file-access-from-files "" , .

, -, . Chromium bug 47416, Chromium Chrome Gecko.

+1

, Chrome 4.1.249.1045 Windows ( Firefox 3.6.3 IE7 [ ]). , ( ): , .

IE7, , : rows, cols frameset, IE . (validator , .)

+1

Source: https://habr.com/ru/post/1794576/


All Articles