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

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Dominic

    #1

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

    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.



    The key idea is

    function getInnerHeight( iframe){
    var d=iframe.conten tWindow ?
    iframe.contentW indow.document :
    iframe.contentD ocument;
    var h=0;
    if(d){
    if(d.documentEl ement && d.compatMode &&
    d.compatMode==" CSS1Compat")
    h=d.documentEle ment.scrollHeig ht;
    else if(d.body)
    h=d.body.scroll Height;
    if(h) h+=getInsets(d) ;
    } return (h||300)+"px"; //300 is a default value
    }

    <iframe src="javascript :top.writeSomeT ext()"
    width="559"
    onload="this.st yle.height=getI nnerHeight(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.contentW indow.document returns "access is denied" error.

    Do you have any idea how to solve this problem?

    Thanks
    Dom
  • Michael Winter

    #2
    Re: &quot;Accsss is denied&quot; when using iframe.contentW indow.document

    On 7 Sep 2004 11:22:04 -0700, Dominic <domtam@hotmail .com> wrote:

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

    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.

    Comment

    • Toby Inkster

      #3
      Re: &quot;Accsss is denied&quot; when using iframe.contentW indow.document

      Dominic wrote:
      [color=blue]
      > It works perfectly if the src of iframe is some local content.
      > Unfortunately, if I put src="http://www.yahoo.com", the line
      > iframe.contentW indow.document returns "access is denied" error.[/color]

      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

      Comment

      • Mark Parnell

        #4
        Re: &quot;Accsss is denied&quot; when using iframe.contentW indow.document

        On 7 Sep 2004 11:22:04 -0700, Dominic <domtam@hotmail .com> declared in
        comp.lang.javas cript,alt.html, microsoft.publi c.scripting.jsc ript:
        [color=blue]
        > It works perfectly if the src of iframe is some local content.
        > Unfortunately, if I put src="http://www.yahoo.com", the line
        > iframe.contentW indow.document returns "access is denied" error.
        >
        > Do you have any idea how to solve this problem?[/color]

        Stop trying to breach copyright.

        --
        Mark Parnell

        "Never drink rum&coke whilst reading usenet" - rf 2004

        Comment

        • Dominic

          #5
          Re: &quot;Accsss is denied&quot; when using iframe.contentW indow.document

          Mark Parnell <webmaster@clar kecomputers.com .au> wrote in message news:<1c10dx50k ytsn$.1urofa4pn kgsq$.dlg@40tud e.net>...[color=blue]
          > On 7 Sep 2004 11:22:04 -0700, Dominic <domtam@hotmail .com> declared in
          > comp.lang.javas cript,alt.html, microsoft.publi c.scripting.jsc ript:
          >[color=green]
          > > It works perfectly if the src of iframe is some local content.
          > > Unfortunately, if I put src="http://www.yahoo.com", the line
          > > iframe.contentW indow.document returns "access is denied" error.
          > >
          > > Do you have any idea how to solve this problem?[/color]
          >
          > Stop trying to breach copyright.[/color]

          I think there may be a misunderstandin g. "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
          misunderstandin g.

          Dom

          Comment

          • Thomas 'PointedEars' Lahn

            #6
            Re: &quot;Accsss is denied&quot; when using iframe.contentW indow.document

            Dominic wrote:
            [color=blue]
            > It works perfectly if the src of iframe is some local content.
            > Unfortunately, if I put src="http://www.yahoo.com", the line
            > iframe.contentW indow.document returns "access is denied" error.[/color]

            <http://groups.google.d e/groups?as_q=Sam e+Origin+Policy &as_ugroup=comp .lang.javascrip t&scoring=d&fil ter=0>

            Please stop crossposting.


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

            Comment

            Working...