I’ve got a simple html code with an iframe on it and I want to access a global variable outside the iframe on the parent.
Anyone knows why chrome doesn’t want to make me happy? 🙂
The code of the iframe works fine in ff,ie,… but not chrome.
Html Code :
<html>
<head>
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.7/jquery.min.js"></script>
<script> var one = "two"; </script>
.....
<body>
<iframe name="process" id="process" src="" frameborder=1></iframe>
</body>
</html>
Iframe Code :
<html>
<head>
<script> alert("Inside step 1 : "+parent.one); </script>
</head>
<body>
STEP 1
</body>
</html>
Unfortunately, you can’t do that in JavaScript. Each iframe is contained in its own
document. Thisdocumentobject contains the global scope of that iframe. You can’t access anything outside of the global scope, so the iframe can only use variables created inside the iframe.