473,395 Members | 1,584 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,395 software developers and data experts.

using iframes in Safari

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 '07 #1
5 14753
On Mar 17, 9:52 am, luckydenis2...@yahoo.com 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 '07 #2
I was able to use it in Firefox. But my problem is Safari.

On Mar 17, 12:08 am, "RobG" <r...@iinet.net.auwrote:
On Mar 17, 9:52 am, luckydenis2...@yahoo.com 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 '07 #3
"RobG" <rg***@iinet.net.auwrote in message
news:11*********************@n76g2000hsh.googlegro ups.com...
On Mar 17, 9:52 am, luckydenis2...@yahoo.com 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').contentWindo w.document.getElementsByTa
gName('img')
[0].height
document.getElementById('testImage').contentWindo w.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
Mar 17 '07 #4
"-Lost" <mi*********@comcast.netwrote in message
news:9Y******************************@comcast.com. ..
"RobG" <rg***@iinet.net.auwrote in message
news:11*********************@n76g2000hsh.googlegro ups.com...
>On Mar 17, 9:52 am, luckydenis2...@yahoo.com 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').contentWind ow.document.getElementsByTa
gName('img')
[0].height
document.getElementById('testImage').contentWind ow.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
Mar 17 '07 #5
ASM
lu************@yahoo.com 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
Mar 17 '07 #6

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

10
by: maxim vexler | last post by:
I'm reading a lot of talks lately about the term iFrame and with your permission would like to ask a few question about that : - what is iFrame, i mean what is it good for ? - does all the...
0
by: Dan Popa | last post by:
Check out the following 2 links: http://www.batisdev.com/admin/test_1images.asp http://www.batisdev.com/admin/test_2images.asp First page contain 4 IFRAMES and 1 IMG tags. Second page contain 4...
5
by: Foreman | last post by:
Using ASPFileUpload (http://support.microsoft.com/default.aspx?scid=kb;en-us;299692) and works for IE6 and FireFox but not Safari. Thanks in advance for your assistance.
4
by: libsfan01 | last post by:
hey this code wont work for my iframe in safari, i cant change the page by changing the src with js: <script language="javascript"> function loadcontent(page) {...
8
by: Kenny Lai | last post by:
hey, Is there a way to communicate between iframes on different subdomains? e.g. from one.dot.com to two.dot.com? there is a security access restriction passing javascript commands between...
8
by: kaaposc | last post by:
Hello! This is not question, I was just wondering, why people continue using frames and iframes when we have handy AJAX approach to fill needed divs with content. Is it because of some user's...
2
by: ericisjusteric | last post by:
I have a page with multiple iframes and need to have the user (ie6) be able to click a button to refresh any one of the iframes - but also to click another button at the top of the page to refresh...
44
by: John Dann | last post by:
I'm unclear as to how best to use what I'm terming the top-level CSS selectors, by which I mean selectors like *, html and body. I'm coming at this from trying to understand how best to set font...
6
by: tinman486 | last post by:
Im new to the whole javascript game, I know pretty much just enough to be dangerous with no real substance. Anyway Im trying to populate a DIV with a website using the URL as an inner html source ...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.