![]() |
![]() |
#1 (permalink) |
Fear the bunny
Location: Hanging off the tip of the Right Wing
|
Browser Redirect Help?
I want a script that will automatically force a user to a certain page should they be using a browser other than IE or Netscape. I think the Java script should be fairly simple, but I don't know how to write it and I can't find what I want anywhere.
Basically, anytime they go to one of my pages, it'll sense what browser they are on, and only allow them onto the page they want if they are using IE or Netscape. Otherwise, they'll be redirected to another page. Thanks. ![]()
__________________
Activism is a way for useless people to feel important. |
![]() |
![]() |
#3 (permalink) |
Banned
Location: 'bout 2 feet from my iMac
|
n0nsensical has it. how 'bout you code to standards instead? That way EVERYONE can see your site.
and here IS the spec: http://www.w3.org/MarkUp/ and here's a validator: http://validator.w3.org/ and here's a poll on who's using what browser rthat suggests you're cutting off half your potential audience: http://www.tfproject.org/tfp/showthr...hlight=browser please note that AS MANY people are using mozilla as are using IE, and ther's another nearly third of the group using konquerer and opera. Seriously, that's just not a good idea, and will hurt your site more than help it. |
![]() |
![]() |
#6 (permalink) |
Fear the bunny
Location: Hanging off the tip of the Right Wing
|
I don't want alternatives. That's like telling someone to get their ear pierced when they're trying to decide which tattoo they should get.
![]() It's not a stupid question, either. I know there's a way to do it, AND SINCE IT'S MY OWN DAMN SITE I CAN DO WHATEVER I WANT WITH IT WITHOUT YOUR PERMISSION! If anyone has actual advice or a place to get the code, then thanks for helping.
__________________
Activism is a way for useless people to feel important. |
![]() |
![]() |
#8 (permalink) |
Tilted
|
Wow, such hositility from the purists. Maybe you need to go back a re-read line #3
http://www.tfproject.org/tfp/showthr...&threadid=1980 |
![]() |
![]() |
#9 (permalink) |
Submit to me, you know you want to
Location: Lilburn, Ga
|
Sorry Boco cant offer what you need, but geez people...this is his website, I'm sure he's got a very good reason for wanting to do this and is it really our place to tell him what to do with his own site? He didnt ask for an opinion on what he was doing, just for the help in doing it.
__________________
I want the diabetic plan that comes with rollover carbs. I dont like the unused one expiring at midnite!! |
![]() |
![]() |
#10 (permalink) |
Upright
|
I strongly recommend against doing this because:
a. first off, the reasons cheerios stated above are *very* valid and I would recommend listening to them b. many browsers other than ie/netscape, for this very reason, have plugins/options to fake useragents, so the website thinks they are IE/netscape even when they are not. I know this works with server-side browser detection, not too sure about client-side (eg. javascript). c. netscape uses the Mozilla gecko rendering engine. So do a lot of other browsers (Mozilla, Mozilla Firebird, Konqueror, Camino), so really you gain nothing by blocking them. Also, a lot of browsers use IE with a different gui (not sure if they change useragents or not though). Apple's safari browser apparently renders very well as well - do you want to alienate many macosx users? With this in mind, if you still want to do it, go ahead, it's your site. Google for "javascript useragent" - it should give you the stuff you want. |
![]() |
![]() |
#11 (permalink) |
Junkie
Location: San Francisco
|
You're right, I didn't answer the question, but I still have the right to complain. =P The way I see it, he's either going to use it to make a site that discriminates against Mozilla, Opera, Safari, etc., or he's going to use it as the answer to a homework problem. Either way, everyone loses because if he publishes it, it's yet another site that uses lame JavaScript to the detriment of the browsing public, and if he uses it as the answer to homework, he doesn't learn how to do it himself and he gets a D on his midterm
![]() Maybe he wants it for neither of those reasons but in any case I'm not going to be the one to publish evil JavaScripts for everyone to find and use for their nefarious purposes. =P Well, I can always uncheck Firebird's handy "Enable JavaScript" box. Also, I don't think we're the ones being hostile... |
![]() |
![]() |
#12 (permalink) |
Everything's better with bacon
Location: In your local grocer's freezer.
|
WTF? Geez, the poor guy asks a simple question and gets slammed, damn. Maybe instead of being self-righteous, you could offer simple advice like, "Do a google search and you should find what you're looking for."
I would never recommend anyone do special coding for Opera or Safari. They don't conform to the standards and they are a huge pain in the ass to code for/around. And before you get all pissed at me maybe you should read what Boco posted originally and then read your responses. He never said, "Can someone tell me the best way to over-complicate a simple request?" But that's what happened. I could go on, but I won't. I'm sure I've pissed off a few of you by posting this, but you really need to get over it.
__________________
It was like that when I got here....I swear. |
![]() |
![]() |
#13 (permalink) |
Fear the bunny
Location: Hanging off the tip of the Right Wing
|
No one even asked if perhaps the page they would be redirect to was going to be designed differently so it'd work with other browsers so I don't have to re-do my current codes.
By the way, I have a few more things to say: 1) If you don't want to help or have nothing nice to say, then just don't post. It's one of the rules of the board. 2) The only reason that anyone uses a browser other than IE (unless they're on a Mac) is because of elitism. Seriously, though, if the only bit of elitism I could muster was that I use a different internet browser than 99.99% of the rest of the world, then I'd probably just kill myself. 3) You people all assumed I was deliberately going to be an ass without me even explaining myself fully. However, not a one of you is my wife or mother so I don't have to explain myself any more than what I want. If I ask a question, please answer it or go away; it's that easy.
__________________
Activism is a way for useless people to feel important. |
![]() |
![]() |
#14 (permalink) | |
Insane
Location: Seattle?
|
Quote:
It's not like any browser I use will care one way or the other. ----- (Please note that I am too tired and indifferent to see whether navigator.appName is actually the right property. I was always more of a server-side guy anyhow ![]() |
|
![]() |
![]() |
#15 (permalink) |
Darth Papa
Location: Yonder
|
You know all the reasons this is a bad idea, BoCo, so I'm going to assume you're the grown-up that I know you are, and that you'll use this thing responsibly.
Code:
<script language="JavaScript" type="text/JavaScript"> if(navigator.appName == "WebTV") { window.location = "WebTVHome.html" } if(navigator.appName == "Netscape") { window.location = "NetscapeHome.html" } if(navigator.appName == "Microsoft Internet Explorer") { window.location = "ExplorerHome.html" } window.location == "Other.html" </script> Note, I didn't write this, I saved myself some time by googling for it. I can't vouch that it'll work anywhere at any time for anybody on any browser or platform. |
![]() |
![]() |
#16 (permalink) | ||||
Junkie
Location: San Francisco
|
Quote:
![]() Quote:
Quote:
Quote:
|
||||
![]() |
![]() |
#17 (permalink) |
undead
Location: nihilistic freedom
|
Hey BoCo,
Couple suggestions: 1) Try using .htaccess file to do the redirection. This is a pretty slick cause your end user won't notice the redirection, it's all done server side. Do something like RewriteCond %{HTTP_USER_AGENT} ... You may or may not be able to configure this depending on your provider. 2) Try using php. I know that might not sound like overkill, but php is really super useful and tons of fun once you learn it. There's probably more efficient ways of doing this, but on my website I do this: PHP Code:
|
![]() |
![]() |
#18 (permalink) |
Everything's better with bacon
Location: In your local grocer's freezer.
|
n0nsensical, let me explain myself a little about not reccommending anyone code around or for Opera or Safari.
One of the things I do for work is help design and implement support systems for enterprise software rollouts. Sometimes this means implementing an HTML based help system and linking it context-sensitively to the application. I don't author the content, but rather create the framework in which the content resides. Managing how that framework works is difficult when you consider 30,000 or more users on average will be using the framework that is being built. Taking into account every possible browser that people COULD use would create havoc with project timelines and increase the cost of the project to the point that it would be prohibitive for the customer to pay for it. That's why, in the business world that I live in, it is important to ignore the lesser used browsers, which is most assuredly what Opera and Safari are, and focus on the mainstream browser(s), which invariably ends up being IE 5.0 and later. Very rarely have I encountered any need to support Netscape, although we do, but it's a HUGE pain in the ass. Further, I have only seen one instance where we needed to support Safari and that was in a university system and that added a couple of weeks to the timeline for development and QA. So, from a realistic perspective, it's more than just stupid to support more than Netscape and IE, it's a waste of time and resources. If it's something you care to do, have a good time, but in the real world of business, it's not a cost effective strategy. BTW, I'm glad I didn't piss you off before ![]()
__________________
It was like that when I got here....I swear. |
![]() |
![]() |
#19 (permalink) |
Junkie
Location: San Francisco
|
And I'm not saying special work should be done to support every browser on the planet either. The W3C already publishes standards that all browsers and websites should conform to. It usually seems to be Internet Explorer that doesn't follow them, and even though IE is the most widely used, I don't think asking for a standards-compliant version of a website is too much. I make the W3C version first and then make necessary changes for IE and only IE, just because it has to be supported. However even IE seems to do pretty well with standard pages. If other browsers have neither standards compliance nor a large userbase, then I agree, let 'em rot and render the pages incorrectly, but I still would never deny any browser completely like I've seen many sites do.
|
![]() |
![]() |
#20 (permalink) | |
Everything's better with bacon
Location: In your local grocer's freezer.
|
Quote:
However, once you introduce Javascript, it starts getting really messy supporting other browsers and can snowball until it becomes a beast. That was where I was coming from....boy, we've come a long way from answering Boco's question, haven't we?
__________________
It was like that when I got here....I swear. |
|
![]() |
![]() |
#21 (permalink) | |
Junkie
Location: San Francisco
|
Quote:
![]() |
|
![]() |
![]() |
#22 (permalink) |
Upright
Location: BC, Canada
|
you could use "internal_redirect" 's with apache and mod_perl. now i know that is not what you were asking for but it would be easier and lot less stressful. you would take the HTTP_USER_AGENT environment var and compare it to a hash of known browsers, then pull a
Code:
$r->internal_redirect($redirect_var);
__________________
- 42 - |
![]() |
![]() |
#23 (permalink) | |
Crazy
Location: N.Ireland
|
I would help you BoCo but im much too afraid you wont appreciate it
Quote:
|
|
![]() |
Tags |
browser, redirect |
|
|