Home Articles FAQs XREF Games Software Instant Books About Feedback Search Site-Map
irt.org logo

Q94 Why do I get an error message when trying to find the location of the document in the parent or sibling frame from another frame?

irt.org | Knowledge Base | JavaScript | Frame | Q94 [ previous next ]

Q94 Why do I get an error message when trying to find the location of the document in the parent or sibling frame from another frame?

Accessing the properties of the frame only works if the page loaded in that frame is on the same server as the document accessing that frame. As soon as the frame contains a page from another server you'll get the following JavaScript alert:

Access disallowed at
http://www.somewhere.com/page1.html to
documents at http://www.somewhereelse.com/page2.htm

You've hit what's called 'Tainting'. Its a security restriction. There's nothing you can do about external pages. However, if you just want to track your own pages, then you could do it in reverse.

Instead of your frame checking the contents of the unknown frame, you could swap it around so that the unknown frame tells your frame what it contains whilst its loading.

In the parent document:

<frameset rows="60,*">
    <frame src="unknown.html" name="unknown" frameborder="0" border="0">
    <frame src="your.html" name="your" frameborder="0" border="0>
</frameset>

In the your.html document:

<form name="loaded">
<input name="display" type="input" size="40">
</form>

And in the unknown.html document:

<html>
<head>
<script language="JavaScript"><!--
parent.your.loaded.display.value = "Its me!";
//--></script>
</head>
<body>
...
</body>
</html>

Provide feedback ...
AddThis Social Bookmark Button

Provide feedback ... AddThis Social Bookmark Button


Last Updated: 30th March 2008. Maintained by: Martin Webb and Michel Plungjan
irt.org liability, trademark, document use, privacy statement and software licensing rules apply.
Copyright © 1996-2008 irt.org, All Rights Reserved.