using iframes in Safari

Discussion in 'Javascript' started by luckydenis2007@yahoo.com, Mar 16, 2007.

  1. Guest

    I am trying to access image information that is displayed using
    iframe.
    iframe code looks like this:
    <iframe id="testImage" src="/images/someimg.gif" scrolling="yes"
    frameborder="0" style="border: 0; width: 280px; height: 455px;"></
    iframe>

    I need to figure out height of the image.

    In Firefox and IE it is not a problem.

    document.getElementById('testImage').contentWindow.document.getElementsByTagName('img')
    [0].height
    document.getElementById('testImage').contentWindow.contentDocument.height

    But in Safari contentWindow is undefined.
     
    , Mar 16, 2007
    #1
    1. Advertising

  2. RobG Guest

    On Mar 17, 9:52 am, wrote:
    > I am trying to access image information that is displayed using
    > iframe.
    > iframe code looks like this:
    > <iframe id="testImage" src="/images/someimg.gif" scrolling="yes"
    > frameborder="0" style="border: 0; width: 280px; height: 455px;"></
    > iframe>
    >
    > I need to figure out height of the image.
    >
    > In Firefox and IE it is not a problem.
    >
    > document.getElementById('testImage').contentWindow.document.getElementsByTa gName('img')
    > [0].height
    > document.getElementById('testImage').contentWindow.contentDocument.height
    >
    > But in Safari contentWindow is undefined.


    contentWindow is an MS proprietary property of frame and iframe
    elements, it may not be supported by browsers other than IE so make
    sure you test for it before attempting to use it.


    --
    Rob
     
    RobG, Mar 17, 2007
    #2
    1. Advertising

  3. Guest

    I was able to use it in Firefox. But my problem is Safari.

    On Mar 17, 12:08 am, "RobG" <> wrote:
    > On Mar 17, 9:52 am, wrote:
    >
    >
    >
    > > I am trying to access image information that is displayed using
    > > iframe.
    > > iframe code looks like this:
    > > <iframe id="testImage" src="/images/someimg.gif" scrolling="yes"
    > > frameborder="0" style="border: 0; width: 280px; height: 455px;"></
    > > iframe>

    >
    > > I need to figure out height of the image.

    >
    > > In Firefox and IE it is not a problem.

    >
    > > document.getElementById('testImage').contentWindow.document.getElementsByTa gName('img')
    > > [0].height
    > > document.getElementById('testImage').contentWindow.contentDocument.height

    >
    > > But in Safari contentWindow is undefined.

    >
    > contentWindow is an MS proprietary property of frame and iframe
    > elements, it may not be supported by browsers other than IE so make
    > sure you test for it before attempting to use it.
    >
    > --
    > Rob
     
    , Mar 17, 2007
    #3
  4. -Lost Guest

    "RobG" <> wrote in message
    news:...
    > On Mar 17, 9:52 am, wrote:
    >> I am trying to access image information that is displayed using
    >> iframe.
    >> iframe code looks like this:
    >> <iframe id="testImage" src="/images/someimg.gif" scrolling="yes"
    >> frameborder="0" style="border: 0; width: 280px; height: 455px;"></
    >> iframe>
    >>
    >> I need to figure out height of the image.
    >>
    >> In Firefox and IE it is not a problem.
    >>
    >> document.getElementById('testImage').contentWindow.document.getElementsByTa
    >> gName('img')
    >> [0].height
    >> document.getElementById('testImage').contentWindow.contentDocument.height
    >>
    >> But in Safari contentWindow is undefined.

    >
    > contentWindow is an MS proprietary property of frame and iframe
    > elements, it may not be supported by browsers other than IE so make
    > sure you test for it before attempting to use it.


    Sure would be nice if the older pages at Mozilla could get a little update. I remember it
    losing out in Mozilla, but cannot find where I read it.

    The original poster can use document.defaultView instead of contentWindow.

    -Lost
     
    -Lost, Mar 17, 2007
    #4
  5. -Lost Guest

    "-Lost" <> wrote in message
    news:...
    > "RobG" <> wrote in message
    > news:...
    >> On Mar 17, 9:52 am, wrote:
    >>> I am trying to access image information that is displayed using
    >>> iframe.
    >>> iframe code looks like this:
    >>> <iframe id="testImage" src="/images/someimg.gif" scrolling="yes"
    >>> frameborder="0" style="border: 0; width: 280px; height: 455px;"></
    >>> iframe>
    >>>
    >>> I need to figure out height of the image.
    >>>
    >>> In Firefox and IE it is not a problem.
    >>>
    >>> document.getElementById('testImage').contentWindow.document.getElementsByTa
    >>> gName('img')
    >>> [0].height
    >>> document.getElementById('testImage').contentWindow.contentDocument.height
    >>>
    >>> But in Safari contentWindow is undefined.

    >>
    >> contentWindow is an MS proprietary property of frame and iframe
    >> elements, it may not be supported by browsers other than IE so make
    >> sure you test for it before attempting to use it.

    >
    > Sure would be nice if the older pages at Mozilla could get a little update. I remember
    > it losing out in Mozilla, but cannot find where I read it.
    >
    > The original poster can use document.defaultView instead of contentWindow.


    Oops, scratch that. I know diddly about Safari, so no clue if what I suggested is an
    alternative or not.

    -Lost
     
    -Lost, Mar 17, 2007
    #5
  6. ASM Guest

    a écrit :
    > I was able to use it in Firefox. But my problem is Safari.


    with Safari the document of iframe is empty ... !
    (for sure ! ! ! :-( )

    Little test (in old JS) :

    <html>
    <iframe id="testImage" name="testImage" src="test.gif" scrolling="yes"
    frameborder="0" style="border: 0; width: 580px; height: 455px;">
    </iframe>

    <form onsubmit="return false;">
    <p>Works with : FF 2, Opera 9, iCab 3.0.3 :
    <button onclick="
    if(parent.testImage.document.images)
    alert(parent.testImage.document.images.length>0);
    ">is there an image ? </button>
    </p>
    <p>Works with : FF 2, Opera 9, iCab 3.0.3 :
    <button onclick="
    if(parent.testImage.document.images)
    alert(parent.testImage.document.images[0].height);">height </button>
    </p>
    <p>Works with : FF 2 *AND* Safari 1.3<br>
    but *NOT* with Opera 9 and iCab 3.0.3, :
    <button onclick="
    var I = new Image();
    I.src = parent.testImage.location;
    alert(I.height);
    ">height </button>
    </p>
    </form>
    </html>

    --
    Stephane Moriaux et son (moins) vieux Mac déjà dépassé
    Stephane Moriaux and his (less) old Mac already out of date
     
    ASM, Mar 17, 2007
    #6
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Gareth

    Using iframes in java.

    Gareth, Jul 28, 2003, in forum: Java
    Replies:
    1
    Views:
    422
    Marco Schmidt
    Jul 28, 2003
  2. xboxsnippets.com

    Using iFrames on your front page

    xboxsnippets.com, Jan 24, 2005, in forum: HTML
    Replies:
    4
    Views:
    529
    gonebye
    Jan 26, 2005
  3. Clyde
    Replies:
    0
    Views:
    92
    Clyde
    Jul 6, 2005
  4. Owen

    Using frames / iframes

    Owen, Sep 12, 2005, in forum: Javascript
    Replies:
    1
    Views:
    84
    Java script Dude
    Sep 13, 2005
  5. libsfan01
    Replies:
    4
    Views:
    141
    Richard Cornford
    Sep 20, 2006
Loading...

Share This Page