homepage Welcome to WebmasterWorld Guest from
register, free tools, login, search, pro membership, help, library, announcements, recent posts, open posts,
Become a Pro Member
Home / Forums Index / Code, Content, and Presentation / JavaScript and AJAX
Forum Library, Charter, Moderator: open

JavaScript and AJAX Forum

Text insertion scheme
IFRAME's and Javascript playing nice?

 5:16 am on Jul 9, 2001 (gmt 0)

I want to be able to use it to run text based promo's for any of our sites running a simple snip of html code. A core server will be responsible for feeding the actual promo code. So I am creating a text insertion system to insert text onto any page running the code. Deciding what browser side code to use has been a challenge.

The html code is based around an IFRAME. That will work for IE5+, NN6, MOZ, and Opera 4+.
I use an external javascript to feed Netscape. The call is placed after the IFRAME and before the closing /IFRAME tag.

<iframe src="textserver.cgi" width="620" height="32" frameborder="0" scrolling="auto">
<SCRIPT LANGUAGE='JavaScript1.2' TYPE="text/javascript">
if (navigator.appName=='Netscape'){
document.write('<s'+'cript src="netscape.js">');

Will I get into any trouble with the javascript call in the "noframe" portion of the IFRAME? I've even thought about skipping the netscape test in the javascript and just feeding the doc write external. For example:

<iframe src="textserver.cgi" width="620" height="32" frameborder="0" scrolling="auto">
<SCRIPT LANGUAGE='JavaScript1.2' SRC='netscape.js' TYPE="text/javascript"></SCRIPT>

I'm a touch leary of that when it comes to compatability.

What do you think of the overall approach? Does it look sound? Any major trouble spots that I could get into.



 10:19 am on Jul 9, 2001 (gmt 0)

Here's a method that avoids JavaScript. It makes use of the fact that only Netscape 4 supports the LAYER tag, so using that tag is like having a built in browser sniffer.

The trick is this: wrap a LAYER in an IFRAME of the same name. NN4 renders the LAYER and ignores the IFRAME. But NN6 and IE4/5 render the IFRAME and ignore the LAYER.

<IFRAME ID="foo" SRC=file.html>
<LAYER NAME="foo" SRC=file.html>

It looks pretty bulletproof to me, but I haven't used it so far.


 11:25 am on Jul 11, 2001 (gmt 0)

Thanks Tedster. It's a very slick trick. That appears to be the ticket for : IE 4+, NN 4+, Moz, Opera 4+. (I've not tried Konquerer yet).

The only one of the big ones it leaves out is Opera 3.62 (my default browser). Livable for the most part. I think leaving out the javascript is worth more that .001% of the browser market.

Global Options:
 top home search open messages active posts  

Home / Forums Index / Code, Content, and Presentation / JavaScript and AJAX
rss feed

All trademarks and copyrights held by respective owners. Member comments are owned by the poster.
Home ¦ Free Tools ¦ Terms of Service ¦ Privacy Policy ¦ Report Problem ¦ About ¦ Library ¦ Newsletter
WebmasterWorld is a Developer Shed Community owned by Jim Boykin.
© Webmaster World 1996-2014 all rights reserved