2 years ago
#67993
Null
Safari sandboxes iframe after opening the parent page for the second time
I have a web page with a single iframe
in the body.
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<meta name="author" content="${cross_identifier}">
<meta name="viewport" content="width=device-width, initial-scale=1, user-scalable=no">
<link rel="icon" type="image/x-icon" href="favicon.ico"/>
<link rel="stylesheet" href="index.css">
<script src="${CMAKE_PROJECT_NAME}.js"></script>
<title>${cross_target}</title>
</head>
<body>
<iframe id="web_view"></iframe>
</body>
</html>
A JS function sets the src
of the iframe
:
document.getElementById('web_view').src = 'assets/' + page + '.htm';
My app works fine in Edge, Firefox, and Chrome but not in Safari:
- Open the app, it works fine for the first time. It even works if I refresh the working page.
- open the app in a new tab or new window, it gives
The frame being accessed is sandboxed and lacks the "allow-same-origin" flag.
error in the line that setssrc
attribute. - Clear history of safari.
- Open the app again and it works.
Not sure if related, but my project has wasm
file as well and cross origin
headers are set like:
- Cross-Origin-Opener-Policy same-origin
- Cross-Origin-Embedder-Policy require-corp
for all files.
Setting Cross-Origin-Resource-Policy same-origin
didn't help.
Setting X-Frame-Options SAMEORIGIN
didn't help.
Link of my app (hope you enjoy playing)
iframe
safari
0 Answers
Your Answer