Welcome to WebmasterWorld Guest from 50.17.16.177

Forum Moderators: open

Message Too Old, No Replies

Text insertion scheme

IFRAME's and Javascript playing nice?

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

Administrator from US 

WebmasterWorld Administrator brett_tabke is a WebmasterWorld Top Contributor of All Time 10+ Year Member Top Contributors Of The Month

joined:Sept 21, 1999
posts:38048
votes: 12


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">');
document.write('</'+'script>');
}
</script>
</iframe>

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>
</iframe>

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 July 9, 2001 (gmt 0)

Senior Member

WebmasterWorld Senior Member tedster is a WebmasterWorld Top Contributor of All Time 10+ Year Member

joined:May 26, 2000
posts:37301
votes: 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>
</LAYER>
</IFRAME>

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

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

Administrator from US 

WebmasterWorld Administrator brett_tabke is a WebmasterWorld Top Contributor of All Time 10+ Year Member Top Contributors Of The Month

joined:Sept 21, 1999
posts:38048
votes: 12


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.

 

Join The Conversation

Moderators and Top Contributors

Hot Threads This Week

Featured Threads

Free SEO Tools

Hire Expert Members