# Browser detection and redirect

**URL:** <https://forum.kirupa.com/t/browser-detection-and-redirect/26025>\
**Category:** Uncategorized\
**Created:** [July 18, 2003, 5:07pm UTC](https://forum.kirupa.com/t/browser-detection-and-redirect/26025 "2003-07-18T17:07:16Z")\
**Posts on this page:** 12\
**Page:** 1

<div class="post-metadata">

**Author:** ![DDD](https://avatars.discourse-cdn.com/v4/letter/d/9fc348/32.png) [@DDD](https://forum.kirupa.com/u/DDD)\
**Post date:** [July 18, 2003, 5:07pm UTC](https://forum.kirupa.com/t/browser-detection-and-redirect/26025/1 "2003-07-18T17:07:16Z")

</div>

Does anyone know where I can find a really good browser detection and redirect script? And yes I know this is DD and this is kinda not the place for it. but eh sue me. I am searching and cannt find a real good one.

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [July 18, 2003, 5:10pm UTC](https://forum.kirupa.com/t/browser-detection-and-redirect/26025/2 "2003-07-18T17:10:39Z")

</div>

i would ask lost…i think he did something like it.

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [July 18, 2003, 5:12pm UTC](https://forum.kirupa.com/t/browser-detection-and-redirect/26025/3 "2003-07-18T17:12:07Z")

</div>

hopefuly he pops in or someone knows of a link

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [July 18, 2003, 5:24pm UTC](https://forum.kirupa.com/t/browser-detection-and-redirect/26025/4 "2003-07-18T17:24:47Z")

</div>

why don’t you use javascripts ? i dont really see another way…  
dreamweaver’s redirection script seem ok to me =)

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [July 18, 2003, 5:34pm UTC](https://forum.kirupa.com/t/browser-detection-and-redirect/26025/5 "2003-07-18T17:34:51Z")

</div>

DW has one?? where?

Yeah I wanna use JS

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [July 18, 2003, 7:05pm UTC](https://forum.kirupa.com/t/browser-detection-and-redirect/26025/6 "2003-07-18T19:05:20Z")

</div>

yeah i didnt know they had one? can you tell us where?

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [July 18, 2003, 8:08pm UTC](https://forum.kirupa.com/t/browser-detection-and-redirect/26025/7 "2003-07-18T20:08:33Z")

</div>

This belongs in Server-Side scripting, so I will move it…

And yes, I did something like that before…

[http://www.kirupa.com/web/browser\_detect.htm](http://www.kirupa.com/web/browser_detect.htm)

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [July 18, 2003, 8:24pm UTC](https://forum.kirupa.com/t/browser-detection-and-redirect/26025/8 "2003-07-18T20:24:16Z")

</div>

hey LIB cool script. But I have a question. How does your script define what is oldns and newns? Like if I want everyone using ns6.0 and below to go here and 6.0 and above go there? I guess what is old and new to your script?

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [July 18, 2003, 8:26pm UTC](https://forum.kirupa.com/t/browser-detection-and-redirect/26025/9 "2003-07-18T20:26:55Z")

</div>

oldNS is anything below NS6. NS6 introduced the ability to use getElementByID, which IE uses as well, but anything before that didn’t have it. So my script checks to see if the version of NS has getElementByID or not.

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [July 18, 2003, 8:29pm UTC](https://forum.kirupa.com/t/browser-detection-and-redirect/26025/10 "2003-07-18T20:29:14Z")

</div>

Ok one last question. So for ie It considers 5.5 new and anything below old or is it 5.0? ANd I take it if it is Opera or some one like that it will just go ahead ad let them thru?

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [July 18, 2003, 8:30pm UTC](https://forum.kirupa.com/t/browser-detection-and-redirect/26025/11 "2003-07-18T20:30:13Z")

</div>

Expansion…

var IE = document.all;

IE has the ability to check the entire document for an object using document.all. So if the browser has that ability, it is IE

var oldNS = document.layers;

oldNS (5-) could had the ability to use layers, so if the browser had the ability to use document.layers, it must be an old NS browser.

var newNS = !document.all && document.getElementById;

The new NS (6+) pretty much has the same ability as IE, but it can’t use the document.all ability. So if it can’t use the document.all ability and it can use getElementById, then it must be a new NS version

var opera = window.opera;

Opera is retarded.

Theres an explantion of how the vars work to check the browser.

A key note: Opera must ALWAYS come first inthe set of if statements. Otherwise it will return the IE page.

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [July 18, 2003, 8:33pm UTC](https://forum.kirupa.com/t/browser-detection-and-redirect/26025/12 "2003-07-18T20:33:09Z")

</div>

> \*Originally posted by 3d-iva \*  
> \*\*Ok one last question. So for ie It considers 5.5 new and anything below old or is it 5.0? ANd I take it if it is Opera or some one like that it will just go ahead ad let them thru? \*\*

It doesn’t check old or new IE. Just IE in general. For IE that is really all you need, there shouldn’t be complications.

Opera… you can define your own opera page, otherwise use the IE page.
