PDA

View Full Version : NN4 Browser Sniffer


jamescover
09-01-2002, 09:51 PM
Hi:

I have a NN4 browser compatability issue that I can't resolve, so I've decided to just create a new page for just NN4.

My question is, can I use JUST the following to do that:


<script>
<!--
/*
**********************************************************
***"I know the plans I have for you, declares the Lord,***
*** plans to prosper you and not to harm you, ***
*** plans to give you hope and a future." ***
**********************************************************
*/
function newWin(){
if (document.layers) {
window.open('http://www.ekigroup.com/Netscape4OnlyPage.html','myWinHybrid','menubar=0,scrollbars=0,location=1,directories=0,toolbar=1,res izeable=0,status=1,width=800,height=600,top=0,left='+((screen.width-800)/2));
}
else {
window.open('http://www.ekigroup.com/allOtherBrowsersPage.html','myWinHybrid','menubar=0,scrollbars=0,location=1,directories=0,toolbar=1, resizeable=0,status=1,width=800,height=600,top=0,left='+((screen.width-800)/2));
}
}
self.moveTo(0,0);
self.resizeTo(screen.width,screen.height);
setTimeout("newWin()",500); //workaround for ie4 new window focus bug.
//-->
</script>



I've tested this in NN4.07 and IE5 and it works perfect, but I was wondering if I was asking for trouble with some other browsers.
Although, as long as it works in NN4+ NS6/7, and IE4+ I'd be happy.

Thing is, I just want the simplest means of sniffing out NN4, and I think that the page will be fine in every other browser, so instead of sniffing out this and that, I just want an either/or situation. If it's NN4, do this, otherwise, do that.

Thanks for any insight.


James
He is risen!!!

mordred
09-02-2002, 02:30 PM
Since you're detecting with document.layers, you are pretty much on the sure side for filtering out NN4. It's the only browser who recognizes this object. And that's far more reliable than dealing with the user agent string.

So I believe your code should work exactly as you supposed. :)

jamescover
09-02-2002, 03:00 PM
Hi mordred:

That's what I thought. But I wanted confirmation, just to make sure. I thought, what could be a simpler browser detection for NN4 than document.layers. And, usually, everything I do is compatable with every other browser, so it's the only one that I need to single out, on occaision.

The problem this time is the size of drawn frames in NN4 verses other browsers. I can't get absolute values to be drawn the exact size in NN4. I even checked Dev Edge, and their own frame sizes are a couple of pixels off, compared to how they are scripted. Unfortunately, this causes some graphic alignment problems on my homepage, because I need to align a graphic in a top frame with one in a botton frame. But it's not going to happen in NN4, so I guess I'll have to code another frameset for NN4 users.

Anyway, thanks for your help. I really appreciate it!


James
He is risen!!!