SitePoint Sponsor |
|
User Tag List
Results 1 to 25 of 40
Thread: Browser redirection script
-
Oct 25, 2001, 07:48 #1
- Join Date
- Jul 1999
- Location
- A cave with 47 computers and an internet feed
- Posts
- 3,559
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
Browser redirection script
Hello
I'm looking for a browser redirection script that will send you to another page if you're not using IE 5+ or Netscape 6. Does anyone know where I can find one?Sherice Jacob - Web Improvement Expert
Improve Website Conversions | eBook Covers
Follow Me on Twitter!
-
Oct 25, 2001, 08:36 #2
- Join Date
- Aug 2001
- Location
- Witty Location Parody
- Posts
- 3,889
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
I have used this one from a1javavscripts, it may work for your situation.
http://www.a1javascripts.com/redirec...rowsR/IE4.html
-
Oct 25, 2001, 08:45 #3
- Join Date
- Jul 1999
- Location
- A cave with 47 computers and an internet feed
- Posts
- 3,559
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
Oh that's just what I was looking for, thank you!
I had found one on HTML goodies, but it was reeeaaally old..from 1997..so this one is much better
PS..love your avatar! We should make him into a smiley for the forumsSherice Jacob - Web Improvement Expert
Improve Website Conversions | eBook Covers
Follow Me on Twitter!
-
Oct 25, 2001, 08:51 #4
- Join Date
- Aug 2001
- Location
- Witty Location Parody
- Posts
- 3,889
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
Hehe, you actually feel like your head is hurting if you stare at it long enuf! Or maybe im just a freak
-
Oct 25, 2001, 09:02 #5
- Join Date
- Jul 1999
- Location
- A cave with 47 computers and an internet feed
- Posts
- 3,559
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
But I'm not using IE 4...
Well I tried it out, and it does exactly what I want it to..but (and I'm sure you knew this was coming...)
It redirects me if I'm using IE 4 or 5 (and I'm not..I'm using 6). I want it to accept IE 5+ and Netscape 6+ but redirect all the other browsers. I'm no javascript genius, but here's the code I have:
<Script><!-- A1 Javascripts-http://www.A1javascripts.com --><!--
if (document.all) //IE4,5
loc = 'content/update.html'
else if (document.images) //NS3,IE4
loc = 'content/update.html'
else //NS2,IE3
loc = 'content/update.html'
window.location = loc;
//--></Script>
How can I fix it so that it redirects the other older browsers, but lets the page show normally for IE 5+ and Netscape 6+ users? :confused:
-
Oct 25, 2001, 11:02 #6
- Join Date
- Oct 2000
- Location
- Nashvegas Baby!
- Posts
- 7,845
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
Here's another script for checking versions:
http://www.mozilla.org/docs/web-deve...wser_type.html
This one checks for every browser known to man apparently.Adobe Certified Coldfusion MX 7 Developer
Adobe Certified Advanced Coldfusion MX Developer
My Blog (new) | My Family | My Freelance | My Recipes
-
Oct 25, 2001, 11:08 #7
- Join Date
- Oct 2001
- Location
- Texas
- Posts
- 96
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
Re: But I'm not using IE 4...
Internet Explorer 5 and above supports both the document.all collection and the document.getElementById method. The following should work for you:
<script language="JavaScript" type="text/javascript">
if(document.all) {
// Do something for IE4
}
else if(document.all && document.getElementById) {
//Do something for IE5+
}
else if(document.layers) {
//do something for NS4.x
}
else if(document.getElementById && !document.all) {
//Do something for NS6+
}
else {
//Do something for everyone else
}
</script>Rob Nolan
Do or do not, there is no try.
-
Oct 25, 2001, 19:13 #8
- Join Date
- Jul 1999
- Location
- A cave with 47 computers and an internet feed
- Posts
- 3,559
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
Would this one work?
<HEAD>
<SCRIPT language="JavaScript">
<!--
var browserVer=parseInt(navigator.appVersion);
if (browserVer >= 5)
{
window.location="http://www.someplace.com/v4.html";
}
else
{
window.location="http://www.someplace.com/other.html";
}
//-->
</SCRIPT>
</HEAD>
redirecting users with Netscape 4.x and below and IE 4 and below to another page?Sherice Jacob - Web Improvement Expert
Improve Website Conversions | eBook Covers
Follow Me on Twitter!
-
Oct 26, 2001, 09:29 #9
- Join Date
- Feb 2000
- Location
- where the World once stood
- Posts
- 700
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
Hi Sparkie,
Yes, it should work, though you might also catch some newer browsers (mozilla, opera) whose versions are 4 or lower.
RogueJedi's script is better because it checks for function/capability. M$ or AOL may come out with a new browser version 1 and your script would have to be rewritten. With Rogue's script, you only need to rewrite it when you begin using 'new, improved' features.
VinnyWhere the World Once Stood
the blades of grass
cut me still
-
Oct 28, 2001, 09:24 #10
- Join Date
- Jul 1999
- Location
- A cave with 47 computers and an internet feed
- Posts
- 3,559
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
I dont see anything in RogueJedi's script that lets me redirect users to another page if they dont use 5+ browsers..?
-
Oct 28, 2001, 12:47 #11
- Join Date
- Oct 2001
- Location
- Texas
- Posts
- 96
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
That would be because I did not put the code for redirection into the example I gave. I left that as an excercise for the reader.
Rob Nolan
Do or do not, there is no try.
-
Oct 28, 2001, 21:11 #12
- Join Date
- Jul 1999
- Location
- A cave with 47 computers and an internet feed
- Posts
- 3,559
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
Hmmmmmmm.. like this?
<script language="JavaScript" type="text/javascript">
if(document.all) {
// Do something for IE4
}
window.location="http://www.someplace.com/1.html";
else if(document.all && document.getElementById) {
//Do something for IE5+
}
window.location="http://www.someplace.com/2.html";
else if(document.layers) {
//do something for NS4.x
}
window.location="http://www.someplace.com/3.html";
else if(document.getElementById && !document.all) {
window.location="http://www.someplace.com/other.html";
//Do something for NS6+
}
else {
window.location="http://www.someplace.com/4.html";
//Do something for everyone else
}
</script>Last edited by Sparkie; Oct 28, 2001 at 21:14.
-
Oct 29, 2001, 16:11 #13
- Join Date
- Oct 2001
- Location
- Texas
- Posts
- 96
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
Yes. Just make sure the necessary code is *inside* the curly braces...
[ ... ]
if(document.all) {
// Do something for IE4
}
window.location="http://www.someplace.com/1.html";
[ ... ]Rob Nolan
Do or do not, there is no try.
-
Oct 30, 2001, 11:03 #14
- Join Date
- Jul 1999
- Location
- A cave with 47 computers and an internet feed
- Posts
- 3,559
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
I keep getting syntax errors. Can you show me exactly how it should be written?
Here is exactly what I have:
<script language="JavaScript" type="text/javascript">
if(document.all) {
// Do something for IE4
}
window.location="http://www.someplace.com/1.html";
else if(document.all && document.getElementById) {
//Do something for IE5+
}
window.location="http://www.someplace.com/2.html";
else if(document.layers) {
//do something for NS4.x
}
window.location="http://www.someplace.com/3.html";
else if(document.getElementById && !document.all) {
window.location="http://www.someplace.com/other.html";
//Do something for NS6+
}
else {
window.location="http://www.someplace.com/4.html";
//Do something for everyone else
}
</script>
I also have another javascript on that page that kills the netscape window-resize but that makes it crash..maybe those two scripts aren't getting along..Last edited by Sparkie; Oct 30, 2001 at 11:08.
-
Oct 30, 2001, 14:07 #15
- Join Date
- Oct 2001
- Location
- Texas
- Posts
- 96
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
You're putting your redirect code outside of the if blocks. Try this instead:
Code:<script language="JavaScript" type="text/javascript"> if(document.all && document.getElementById) { //Do something for IE5+ window.location="http://www.someplace.com/2.html"; } else if(document.all) { // Do something for IE4 window.location="http://www.someplace.com/1.html"; } else if(document.layers) { //do something for NS4.x window.location="http://www.someplace.com/3.html"; } else if(document.getElementById && !document.all) { window.location="http://www.someplace.com/other.html"; //Do something for NS6+ } else { window.location="http://www.someplace.com/4.html"; //Do something for everyone else } </script>
Rob Nolan
Do or do not, there is no try.
-
Oct 30, 2001, 19:54 #16
- Join Date
- Jul 1999
- Location
- A cave with 47 computers and an internet feed
- Posts
- 3,559
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
Thank you very much Rob! Your help has been unbelievably appreciated
-
Oct 30, 2001, 21:23 #17
- Join Date
- Jul 1999
- Location
- A cave with 47 computers and an internet feed
- Posts
- 3,559
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
Hmm. Seems I've spoken too soon!
Now the pages just keep trying to load over and over again!
-
Oct 30, 2001, 23:37 #18
- Join Date
- Oct 2001
- Location
- Texas
- Posts
- 96
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
I replied to your PM.
Rob Nolan
Do or do not, there is no try.
-
Oct 31, 2001, 09:38 #19
- Join Date
- Jul 1999
- Location
- A cave with 47 computers and an internet feed
- Posts
- 3,559
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
I still dont understand what the problem could be (I PMmed you again). If on my index.html page, I have the script set to redirect you to an update page if you're using an outdated browser, and on to the index.html page if you're using the right browser...that wouldn't work for each html page (if you're using the correct filename for each one)?
-
Oct 31, 2001, 09:40 #20
- Join Date
- Jul 2001
- Location
- East Side
- Posts
- 98
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
If you are using Dreamweaver, there is an extension you can download from the Macromedia site that will do this for you with only a few clicks!
-
Nov 2, 2001, 11:49 #21
- Join Date
- Jul 1999
- Location
- A cave with 47 computers and an internet feed
- Posts
- 3,559
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
mmmkay, I copied the script to the index.html file, and I have it set to redirect users to index.html if they have the right browser..and update.html if they do not.
But the problem is that the script keeps repeating itself..what should I do?
-
Nov 2, 2001, 17:28 #22
- Join Date
- Feb 2000
- Location
- where the World once stood
- Posts
- 700
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
Hi sparkie,
Could you post a url (it might save time
1) what exactly does your code look like?
2) where are you calling it from?
3) where is it located?
4) are the locations correctly spelled (case counts)?
5) which browser is giving you the problem?
6) are any of the browsers redirecting to the same page? that is, are you saying something like:
if (document.all) window.location=thispage where thispage is the index page? if so, you shouldn't. You do not need to redirect browsers that are ok, only those that are not ok. The only case in which you would redirect everyone is if the 'index.html' page does only one thing -- redirect.
VinnyWhere the World Once Stood
the blades of grass
cut me still
-
Nov 3, 2001, 10:29 #23
- Join Date
- Jul 1999
- Location
- A cave with 47 computers and an internet feed
- Posts
- 3,559
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
Oh! I'll try that out..thats probably what was causing the problem (redirecting the latest browsers)
Thanks so much Vincent!
-
Nov 8, 2001, 15:03 #24
- Join Date
- Jul 1999
- Location
- A cave with 47 computers and an internet feed
- Posts
- 3,559
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
Whaaaa?
I've got the following code in there now:
<script language="JavaScript" type="text/javascript">
if(document.all && document.getElementById) {
// Do something for IE4
window.location="http://www.collegetec.com/intstudies/content/update.html";
}
else if(document.layers) {
//do something for NS4.x
window.location="http://www.collegetec.com/intstudies/content/update.html";
}
else {
window.location="http://www.collegetec.com/intstudies/content/.html";
//Do something for everyone else
}
</script>
-
Nov 8, 2001, 15:25 #25
- Join Date
- Oct 2001
- Location
- Texas
- Posts
- 96
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
That's because your test is for IE5+, not for IE4. To test for IE4 just use if(document.all).
Rob Nolan
Do or do not, there is no try.
Bookmarks