Categories: pre-65 (older versions) : Report an Issue :

Chrome javascript issue: No variable scope from IFRAME to parent frame

Showing 1-2 of 2 messages
Chrome javascript issue: No variable scope from IFRAME to parent frame Peter Dow 7/20/14 6:59 AM
First, a by-the way as to why I am using portable Chrome. I'm running Chrome portable Version 22.0.1229.94 on Windows XP - portable allows me to use a non-system directory to install the files onto and for the webpage cache thus saving system disc space which is running out.

The standard version of Chrome didn't allow me to choose and insisted on installing itself on the system disc.

Also by the way, yes I know that's an old version and someone will suggest installing the latest version to see if that fixes the error but anyway here is the issue that I want a solution to.

Have you checked our known issues page?  YES - DIDN'T SEE IT.

If your issue is not there, please provide a detailed description here

Javascript doesn't work as it should, as it does for example even on Internet Explorer 7 which I also use.

Specifically, the javascript which allows you to address variables between frames, say between a web page and an embedded IFRAME webpage, doesn't work as it should.

Here is couple of test files that demonstrate the failure of Chrome.

<meta http-equiv="content-type" content="text/html; charset=iso-8859-1">
<body bgcolor=pink>


<iframe name="iframename" src="doc2.htm"></iframe>
<br />
<a href="#" onclick="alert('The value of the variable test_var set by a script in DOC2.HTM embedded in the DOC1.HTM page by an iframe named IFRAMENAME as read from a script running in DOC1.HTM appears to be - ' + window.iframename.test_var);return false;">check variable</a>


<meta http-equiv="content-type" content="text/html; charset=iso-8859-1">

<script type="text/javascript">

var test_var="testing, testing . . .";


<body bgcolor=red>

So run that in Chrome and the variable set in DOC2.HTM remains undefined - it's out of scope.

Run it in Internet Explorer and the variable is set, no problem.

The same issue arises trying to read variables the other way by using parent.variable_name from the embedded frame trying to address variables in the parent file.

The only info I get from Chrome, is a lame, worthless excuse in the Console, thus.

Unsafe JavaScript attempt to access frame with URL ... ... /doc2.htm from frame with URL ../doc1.htm. Domains, protocols and ports must match.

I've edited out the folder names from the console message for clarity.

Given the extensive javascript support of Chrome compared to the primitive offerings of IE7 in that respect, I would have expected better from Chrome, that basic functions of Javascript would work.

So what's up Chrome?

I'd really like replies to be sent to _________

(Editor's Note: This post has been revised to remove personal, confidential information. As a reminder to all users, please visit the Content Policy page to review the guidelines before posting in the Forums. Thanks!)
Re: Chrome javascript issue: No variable scope from IFRAME to parent frame Peter Dow 7/20/14 9:14 PM
I have a work-around for this issue in Chrome.

Thanks to Lucy24 on WebmasterWorld for helping.

This issue with Chrome arose when my javascript was being tested off line and files doc1.htm and doc2.htm are in the same folder on my PC. 

Moving the doc1.htm & doc2.htm files to a folder where I test my server side php programs, which runs using Windows Internet Services Manager means I can address the files using http://localhost addresses and bingo, Chrome behaves as it should have behaved in offline mode. 

It is not "legitimate" in my opinion for Chrome's javascript not to be able to directly address files in the same offline folder.

There's absolutely no security issue when you are running your own javascript files on your own PC. Or if Chrome wanted to offer a security setting that allowed or disallowed offline IFRAME variable scoping then OK, that would be fine. 

The error message is not at all clear I submit and Lucy24 did well to figure out what it meant. 

If Internet Explorer and Firefox etc allow you to test your javascript offline then why not Chrome? 

So well done Lucy24. Not so well done Chrome.