Argh! Calling parent functions from a page within an iframe

  • pompei
  • Graduate
  • Graduate
  • No Avatar
  • Joined: Dec 19, 2003
  • Posts: 117
  • Status: Offline

Post February 26th, 2004, 4:48 pm

Hi everyone,

This is currently getting me pulling my hair out. I want to be able to call a function on a page from a page within an iframe on that page. e.g.:

Parent document (siteX.com):

Code: [ Select ]
<script language="Javascript">
function test() { alert('test works'); };
</script>

.. some html

<iframe src="http://siteY.com/page_y.htm"></iframe>
  1. <script language="Javascript">
  2. function test() { alert('test works'); };
  3. </script>
  4. .. some html
  5. <iframe src="http://siteY.com/page_y.htm"></iframe>


And then on page_y this code should work:

Code: [ Select ]
<script language="Javascript">
parent.test();
</script>
  1. <script language="Javascript">
  2. parent.test();
  3. </script>


The problem is, this works when both pages are part of the same site, but not when page_y is on a different site than the one that places it in an iframe.

Any help!?
  • Anonymous
  • Bot
  • No Avatar
  • Joined: 25 Feb 2008
  • Posts: ?
  • Loc: Ozzuland
  • Status: Online

Post February 26th, 2004, 4:48 pm

  • RichB
  • Guru
  • Guru
  • User avatar
  • Joined: May 17, 2003
  • Posts: 1121
  • Loc: Boston
  • Status: Offline

Post February 26th, 2004, 5:16 pm

I don't think this is possible when the document is on a different site. This came up in a different thread a while back. After some research we came across a document at Microsoft that explains that cross-frame scripting between domains in not allowed for security reasons.

The article is here:

http://msdn.microsoft.com/library/defau ... curity.asp
Free Programming Resources
  • pompei
  • Graduate
  • Graduate
  • No Avatar
  • Joined: Dec 19, 2003
  • Posts: 117
  • Status: Offline

Post February 26th, 2004, 5:23 pm

Hey RichB,

Thanks for the thread, I had a hunch it wasn't possible :cry:

Post Information

  • Total Posts in this topic: 3 posts
  • Users browsing this forum: No registered users and 207 guests
  • You cannot post new topics in this forum
  • You cannot reply to topics in this forum
  • You cannot edit your posts in this forum
  • You cannot delete your posts in this forum
  • You cannot post attachments in this forum
 
 

© 2011 Unmelted, LLC. Ozzu® is a registered trademark of Unmelted, LLC.