Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Javascript > "Accsss is denied" when using iframe.contentWindow.document

Reply
Thread Tools

"Accsss is denied" when using iframe.contentWindow.document

 
 
Dominic
Guest
Posts: n/a
 
      09-07-2004
Hi everybody,

My goal is to set the height of the iframe to fit its content. There
was an earlier posting which gave some useful insights.

http://groups.google.com/groups?hl=e...BIFrame%2Bsize

The key idea is

function getInnerHeight(iframe){
var d=iframe.contentWindow ?
iframe.contentWindow.document :
iframe.contentDocument;
var h=0;
if(d){
if(d.documentElement && d.compatMode &&
d.compatMode=="CSS1Compat")
h=d.documentElement.scrollHeight;
else if(d.body)
h=d.body.scrollHeight;
if(h) h+=getInsets(d);
} return (h||300)+"px"; //300 is a default value
}

<iframe src="javascript:top.writeSomeText()"
width="559"
onload="this.style.height=getInnerHeight(this)"></iframe>

It works perfectly if the src of iframe is some local content.
Unfortunately, if I put src="http://www.yahoo.com", the line
iframe.contentWindow.document returns "access is denied" error.

Do you have any idea how to solve this problem?

Thanks
Dom
 
Reply With Quote
 
 
 
 
Toby Inkster
Guest
Posts: n/a
 
      09-07-2004
Dominic wrote:

> It works perfectly if the src of iframe is some local content.
> Unfortunately, if I put src="http://www.yahoo.com", the line
> iframe.contentWindow.document returns "access is denied" error.


It looks like an XSS thing -- there probably isn't a way around it. If
there is a way around it then the workaround will probably stop working
when you upgrade your browser.

--
Toby A Inkster BSc (Hons) ARCS
Contact Me ~ http://tobyinkster.co.uk/contact
Now Playing ~ ./keane/hopes_and_fears/08_sunshine.ogg

 
Reply With Quote
 
 
 
 
Michael Winter
Guest
Posts: n/a
 
      09-07-2004
On 7 Sep 2004 11:22:04 -0700, Dominic <(E-Mail Removed)> wrote:

[snip]

> It works perfectly if the src of iframe is some local content.
> Unfortunately, if I put src="http://www.yahoo.com", the line
> iframe.contentWindow.document returns "access is denied" error.
>
> Do you have any idea how to solve this problem?


Generally, it can't be. See the FAQ, specifically section 4.19, for more
information.

<URL:http://jibbering.com/faq/>

Mike

--
Michael Winter
Replace ".invalid" with ".uk" to reply by e-mail.
 
Reply With Quote
 
Mark Parnell
Guest
Posts: n/a
 
      09-07-2004
On 7 Sep 2004 11:22:04 -0700, Dominic <(E-Mail Removed)> declared in
comp.lang.javascript,alt.html,microsoft.public.scr ipting.jscript:

> It works perfectly if the src of iframe is some local content.
> Unfortunately, if I put src="http://www.yahoo.com", the line
> iframe.contentWindow.document returns "access is denied" error.
>
> Do you have any idea how to solve this problem?


Stop trying to breach copyright.

--
Mark Parnell
http://www.clarkecomputers.com.au
"Never drink rum&coke whilst reading usenet" - rf 2004
 
Reply With Quote
 
Dominic
Guest
Posts: n/a
 
      09-08-2004
Mark Parnell <(E-Mail Removed)> wrote in message news:<1c10dx50kytsn$.1urofa4pnkgsq$(E-Mail Removed) >...
> On 7 Sep 2004 11:22:04 -0700, Dominic <(E-Mail Removed)> declared in
> comp.lang.javascript,alt.html,microsoft.public.scr ipting.jscript:
>
> > It works perfectly if the src of iframe is some local content.
> > Unfortunately, if I put src="http://www.yahoo.com", the line
> > iframe.contentWindow.document returns "access is denied" error.
> >
> > Do you have any idea how to solve this problem?

>
> Stop trying to breach copyright.


I think there may be a misunderstanding. "http://www.yahoo.com" is
only used to illustrate the situation of getting some remote content.
The remote content may come from our server of another domain name, or
from our partner. I realize that this is a problem as long as the data
is not located at local server.

Hope it is clear. I'm sorry if my earlier posting leads to the
misunderstanding.

Dom
 
Reply With Quote
 
Thomas 'PointedEars' Lahn
Guest
Posts: n/a
 
      09-11-2004
Dominic wrote:

> It works perfectly if the src of iframe is some local content.
> Unfortunately, if I put src="http://www.yahoo.com", the line
> iframe.contentWindow.document returns "access is denied" error.


<http://groups.google.de/groups?as_q=Same+Origin+Policy&as_ugroup=comp.lang .javascript&scoring=d&filter=0>

Please stop crossposting.


PointedEars, F'up2 cljs
--
The truth is out there... and so are the bugs...
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Using a Link Button to redirect to another page by using data from =?Utf-8?B?R1REcml2ZXI=?= ASP .Net 1 02-16-2005 07:04 PM
Error page using the Application_Error void dosnt work when using DIV for a please wait message s_erez@hotmail.com ASP .Net 2 12-24-2004 12:11 PM
no code in webform using vs.net, but in webform using notepad timmso ASP .Net 1 12-12-2003 04:30 PM
Using GetOleDbSchemaTable to get SQL Server Field Description - using pete ASP .Net 1 08-29-2003 10:50 AM
Re: MVP? Index error on nested element using System.xml but NOT using msxml??? William F. Robertson, Jr. ASP .Net 1 06-25-2003 08:08 PM



Advertisments