It is currently Fri May 18, 2012 5:03 pm


Post a new topicPost a reply Page 1 of 1   [ 1 post ]
Author Message
 Post subject: JavaScript Permission Denied Error for IFRAME
PostPosted: Wed Dec 10, 2008 9:11 am 
Site Admin

Joined: Sat Aug 02, 2008 8:00 am
Posts: 147
When using an IFRAME on the page and defining the src of the contents of the IFRAME to be from another server hostname:port and then trying to access the contents of the IFRAME using the contentwindow or the contentdocument properties you get the permission denied error.

The reason is that for security issues the latest Internet browsers blocked the access to the DOM objects that are returned from locations that are not the same as the location of the containing page and this is called "The Same Origin Policy"

I Examined the returned DOM myself using firebug and found that the returned contentwindow and contentdocument are appearing to be empty for firebug.

After searching online I found 2 approaches described as solution for this problem
the first approach is to change the document.domain property in either the containing or the contained pages
this claims that the browser will validate the same origin policy based on the domain property
although the mozilla website says that firefox validates the same origin based n the hotstname and the port and that changing the document.domain will erase this error I found that changing the document.domain did not fix the problem.
The other approach is using AJAX to query the contents and using a proxy to pass this request I found that this solution is costy to set up a proxy just for this purpose.

I tried another approach by changing the header of the returned response from the contained page using the response.setHeader method to set the host header to the hostname and port of the containing page and that did not work as well

finally I found there is no escape from having both pages to be served on the same server (hostname and port)

If anyone could find a solution for this problem please prompt and share it

Thanks

_________________

Muhammad Safwat Fuad
The Java Code Admin
Java Technical Lead.
Mobile: +2010-2942-538
Email:mtv134@yahoo.com


Top
 Profile Send private message  
 
Display posts from previous:  Sort by  
Post a new topicPost a reply Page 1 of 1   [ 1 post ]


Who is online

Registered users: MissYtry, Salpkalawar


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

Jump to:  
cron


Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group
twilightBB Style by Daniel St. Jules of Gamexe.net

[
SEO MOD © 2007 StarTrekGuide ]