Closed Thread Icon

Topic awaiting preservation: browser chaos!? (Page 1 of 1) Pages that link to <a href="https://ozoneasylum.com/backlink?for=8323" title="Pages that link to Topic awaiting preservation: browser chaos!? (Page 1 of 1)" rel="nofollow" >Topic awaiting preservation: browser chaos!? <span class="small">(Page 1 of 1)</span>\

 
Gweilo
Bipolar (III) Inmate

From: switzerland
Insane since: Sep 2002

posted posted 09-26-2002 20:22

hi,

I'm working on some DHTML, and don't know, how to set/move layers (and test for the exceptions, of course) in all the "exotic" browsers. Up to now I have:

var N = (navigator.appName=='Netscape')? 1:0
var I = (navigator.appName=='Microsoft Internet Explorer')? 1:0

if (N) window.document.layername.left=x;
if (I) layername.style.left=x;

if (N) window.document.layername.visibility="visible";
if (I) layername.style.visibility="visible";

Does this work with Opera and all the other browsers? or do I have to add a third (or 5th etc) if-condition?
It's confusing enough with 2 browsers alone, so why the hell don't these companies make all javascript the same? -> oh, I forgot, one of the companies is Microsoft =) [but actually I prefer MSIE to NN]

Oh, and by the way, is there a possibility to make the script work for both?
for example:

if (I){
var front="";
var back="style"}
else {var front="window.document";
var back="";}

front.layername.back.top=100; // this here should work for all browsers... but it doesn't *g*

Thanks for your help!

BTW: the homepage I'm currently working on is on http://www.kasag.com/phoenix
* I was somehow inspired by your main entry script "lost v2.0" =)

Slime
Lunatic (VI) Mad Scientist

From: Massachusetts, USA
Insane since: Mar 2000

posted posted 09-26-2002 21:43

I'm afraid you're using extremely old techniques. I recommend you read this tutorial:
http://www.scottandrew.com/weblog/articles/dom_1
And then maybe this one: http://www.scottandrew.com/weblog/articles/dhtml_ns6

Both from www.scottandrew.com .

Gweilo
Bipolar (III) Inmate

From: switzerland
Insane since: Sep 2002

posted posted 09-26-2002 21:52

erm, ok, but will this work for Browsers with Version 4 or 5?

Slime
Lunatic (VI) Mad Scientist

From: Massachusetts, USA
Insane since: Mar 2000

posted posted 09-26-2002 23:11

version 5 and 6 browsers, actually. And 7, when they start to come out.

Version 4 browsers are getting quite old. If they're a concern to you for some reason or other, then you'll have to continue testing for document.layers (which reveals an NN4.x user) or document.all (which reveals an IE user). But when document.getElementById exists, it's almost always best to use that instead.

Don't test specifically for the Navigator.appName. Do something like

var RecentBrowser = (document.getElementById)?true:false; // should use newer DOM methods
if (!RecentBrowser) {
var OldIE = (document.all)?true:false; // should use document.all
var OldNN = (document.layers)?true:false; // should use document.layers
}

But honestly, if you don't have a specific reason for wanting to please version 4 browser users, then I wouldn't recommend that you worry about it.

Hugh
Paranoid (IV) Inmate

From: Dublin, Ireland
Insane since: Jul 2000

posted posted 09-27-2002 13:35

yup, there quite right for example:
if (N) window.document.layername.visibility="visible";
this should be:
if (N) window.document.layername.visibility="show";
for Netscape 4. Neither will work for Netscape 6.

and the window. isnt needed BTW.
and your missing document.all/document.getElementById()

really that code is very old. Even the way you set I & N to true or false, its much smarter using something like:
IE=(document.all)?1:0;
NS=(document.layers)?1:0;
if(!IE)DOM=(document.getElementById)?1:0;
etc..

there are still flaws with this, for opacity and such. Remember IE is backward compatably unlike NS.



« BackwardsOnwards »

Show Forum Drop Down Menu