0

I'm trying to simplify my problem, and I don't think it could be simpler than this:

<html>
<frameset rows = "50%,50%" name="proof">
<frame src="one.html" name="one">
<frame src="two.html" name="two">
</frameset>
</html>

<html>
<body>
<H1>Frame 1</H1>
</body>
</html>

<html>
<body>
<H1>Frame 2</H1>
</body>
</html>

This is what I see when I load the frameset:

[https://ibb.co/LSMpgZF]

If I edit the file with "Frame 2" this way:

<html>
<body>
<H1>Frame 2</H1>
<script>
alert (top.two.name);
</script>
</body>
</html>

and I reload the frameset, I see this:

https://ibb.co/Qkkhp69

Until now, everything works as expected. But if I edit the file with "Frame 2" this other way:

<html>
<body>
<H1>Frame 2</H1>
<script>
alert (top.one.name);
</script>
</body>
</html>

no alert appears, despite having done exactly what everyone on the Internet is suggesting. The same happens with the other frame: it can display its own name, but not the other's (or the frameset's).

Why is that? How can the two frames communicate?

Andrea Carta
  • 33
  • 1
  • 5
  • 3
    I guess you know that apparently fames are deprecated (in favour of iframes)? Not an answer to your question I realise, but you may like to look into using iframes. – A Haworth May 26 '21 at 20:52
  • Well, if nothing can be done with frames, I'll switch to iframes. – Andrea Carta May 26 '21 at 23:00
  • It's more that frames might stop working on any browser at any time so if this is for a site that will be providing a service it's worth thinking of switching now. – A Haworth May 27 '21 at 04:53
  • No, it's for internal use. But apart from that, I'd like to know what's wrong with my code. It doesn't work on any browser. – Andrea Carta May 27 '21 at 08:03
  • By the way, after what you wrote I tried switching to iframes, but the behavior did not change: iframes too can display their own name, but not the others', that is what I need. Maybe there's something in the settings of my browser? – Andrea Carta May 27 '21 at 10:18

1 Answers1

0

OK, I solved the issue myself.

I tried many variations, and above all I placed both alerts in the same html file. I noticed the alert displaying its own name was correctly executed only if it was the first one. So I guessed there was a JS error somewhere in the other alert and indeed there was one - I eventually located the error in the Firefox console. It was caused by a browser security setting, as I suspected, and some good solutions can be found in this other thread: Disable firefox same origin policy

This worked perfectly for me (as I'm using Firefox): after Firefox 68 I need to adjust 'privacy.file_unique_origin' -> false (by open 'about:config') to solve 'CORS request not HTTP' for new CORS same-origin rule introduced.

Andrea Carta
  • 33
  • 1
  • 5