473,395 Members | 1,629 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.

Crossbrowser iframes

I want to load content into an iframe with script. None of the
following methods, however, work on all browsers - any suggestions
would be appreciated.

// Assume that there is an element whose name and id are both
// 'theIFrame'.

var myUrl='http://www.yahoo.com'

document.getElementById( 'theIFrame' ).location=myUrl;

document.getElementById( 'theIFrame' ).src=myUrl;

window.document.theIFrame.location=myUrl;

var iframe=document.createElement( 'iframe' );
iframe.src=myUrl;
document.body.appendChild( iframe );

--
Christopher Benson-Manica | I *should* know what I'm talking about - if I
ataru(at)cyberspace.org | don't, I need to know. Flames welcome.
Jul 23 '05 #1
2 1560
In article <d2**********@chessie.cirr.com>, at***@nospam.cyberspace.org
enlightened us with...
I want to load content into an iframe with script. None of the
following methods, however, work on all browsers - any suggestions
would be appreciated.

Standards support frameElement.src, so I'd go with just using that. Both
Gecko (firefox, moz, NN6+) and MSIE support it.

MSIE: http://msdn.microsoft.com/workshop/a...ties/src_2.asp


Gecko:
http://www.mozilla.org/docs/dom/domr...ame_ref13.html

W3C HTML 4.01 specs:
http://www.w3.org/TR/html4/present/f...ml#edef-IFRAME

If other browsers can't handle it, oh well. Very few script-type things work
on every single browser in existence. Actually, if you count the text-only
browsers, none do! :p
(do test for an object before using it so it doesn't KILL the non-standard
browsers)

You asked for suggestions, so that's just one. I'm sure someone will come
along with a big long script that works in 15 browsers. *heh*
AFAIC, I support whatever the W3C has and whatever is needed (if anything) to
make it work in Firefox and MSIE.

--
--
~kaeli~
If that phone was up your a$$, maybe you could drive a
little better!
http://www.ipwebdesign.net/wildAtHeart
http://www.ipwebdesign.net/kaelisSpace

Jul 23 '05 #2


Christopher Benson-Manica wrote:
I want to load content into an iframe with script. None of the
following methods, however, work on all browsers - any suggestions
would be appreciated.

// Assume that there is an element whose name and id are both
// 'theIFrame'.

var myUrl='http://www.yahoo.com'


Make sure the name in the <iframe> tag is set then use
if (window.frames['theIframe']) {
window.frames['theIframe'].location.href = myUrl;
}
That gives you IE 4 and later, Netscape 6 and later, Opera 6 and later
and hopefully other browsers implementing window.frames.

--

Martin Honnen
http://JavaScript.FAQTs.com/
Jul 23 '05 #3

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: Frances | last post by:
I need to replace iframes acc. to what option user chooses in a sel obj.. but figured have to load a blank iframe when pg loads so I can replace it.. (iframe gets put in a pre-existing div..) this...
2
by: Guadala Harry | last post by:
1. Are IFrames supported only in uplevel versions of IE? If not IE exclusively, what browsers support IFrames? 2. Are IFrames going to be supported in the future - as far as anyone knows - or...
3
by: Steel | last post by:
Hi at all, I'ld want to know if position:absolute is crossbrowser. Infact I cannot position absolutely an element in the some place with fox-pro and MSIE6 There is always a little difference...
19
by: wmanzo | last post by:
I have a really professional conspiracy movie site and I use tons of layers and an external scroll bar assembly. I would like to put the various sections into MS Iframes and in order to clean up...
53
by: brave1979 | last post by:
Please check out my javascript library that allows you to create any layout for your web page, nested as deep as you like, adjusting to width and height of a browser window. You just describe it in...
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...
1
by: par7133 | last post by:
Hi, Yea, XMLHttpRequest give out a crossbrowser problem managing the status change of the connection. Here the solution: var xmlhttp; xmlhttp=null;
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
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
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
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...

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.