| Coding Forum Problems with your code? Let's hear about it. |
12-04-2003, 09:59 AM
|
#1 (permalink)
|
|
No Longer Here
Join Date: 09-27-03
Location: State College, PA
Posts: 9,354
Latest Blog: None
|
Browser Detection
I am putting a javascript on a website that will pop up an alert box if the user is using Netscape 4.
Here is what I found to use:
[code:1:7614b0e64e]<script>
function checkbrowser()
{
//detect browser properties
var app = navigator.appName;
var ver = navigator.appVersion;
var agent = navigator.userAgent;
var code = navigator.appCodeName;
var plat = navigator.platform;
//detect netscape 4 browser
if ((agent.indexOf("4.")>-1) && (app=='Netscape'))
{
//open browser alert window
var
n=open('http://phpserver.kcnet.org/alert.html','browseralert','width=600,height=400,m enubar=no,scrollbars=yes,resizable=no,'
);
}
}
</script>[/code:1:7614b0e64e]
My question:
How can I make this only pop up once?
|
|
|
12-04-2003, 10:37 AM
|
#2 (permalink)
|
|
Inactive
Join Date: 10-12-03
Location: Minnesota, USA
Posts: 2,207
Latest Blog: None
|
Could you make that a seperate js file and use the include_once() function? Or am I insane and need to read my book more?
|
|
|
12-04-2003, 01:09 PM
|
#3 (permalink)
|
|
No Longer Here
Join Date: 09-27-03
Location: State College, PA
Posts: 9,354
Latest Blog: None
|
I changed my mind on what I want.
I want something so they can say "don't show this message again". If they don't chose that, the box will come up every time.
Anyone know how to do that? I have been searching, but can't find anything.  Is this even possible?
|
|
|
12-04-2003, 02:33 PM
|
#4 (permalink)
|
|
Moderator
Join Date: 10-13-03
Location: UK
Posts: 2,819
Latest Blog: None
|
u'd probably have to set a cookie that remembers they've chosen "don't show this message again".
|
|
|
12-04-2003, 02:34 PM
|
#5 (permalink)
|
|
No Longer Here
Join Date: 09-27-03
Location: State College, PA
Posts: 9,354
Latest Blog: None
|
You're here  I was going to post something about how you shouldn't be allowed to leave the forum
How do I set a cookie for that?
|
|
|
12-04-2003, 02:38 PM
|
#6 (permalink)
|
|
Moderator
Join Date: 10-13-03
Location: UK
Posts: 2,819
Latest Blog: None
|
oh an (ugly) solution would be to make all your internal links have ?msg=false on the end after they choose to not see the message.
and your script would check to see if the address has ?msg=false on the end when enterign the page (and if so does not show the message).
Thas can be done by the script, and would only happen on nn4 (because u've detected it and only run the script for nn4).
you're current script can be cleaned up a lot...
|
|
|
12-04-2003, 02:42 PM
|
#7 (permalink)
|
|
Moderator
Join Date: 10-13-03
Location: UK
Posts: 2,819
Latest Blog: None
|
I am not to confident on scripting for NN4, so bare with me.
Would you like the ?msg=false solution or the one that relies on cookies?
(I'm not even sure if nn4 supports cookies! :S ??)
|
|
|
12-04-2003, 02:42 PM
|
#8 (permalink)
|
|
No Longer Here
Join Date: 09-27-03
Location: State College, PA
Posts: 9,354
Latest Blog: None
|
I'll go with whatever you think is best 
|
|
|
12-04-2003, 02:42 PM
|
#9 (permalink)
|
|
Inactive
Join Date: 10-12-03
Location: Cranberry Township
Posts: 275
|
bah, it's netscape 4, so chances are it will only be seen once anyway 
|
|
|
12-04-2003, 02:43 PM
|
#10 (permalink)
|
|
Moderator
Join Date: 10-13-03
Location: UK
Posts: 2,819
Latest Blog: None
|
Quote:
|
Originally Posted by Jazzee
You're here  I was going to post something about how you shouldn't be allowed to leave the forum 
|
hahah! 
|
|
|
12-04-2003, 02:45 PM
|
#11 (permalink)
|
|
Moderator
Join Date: 10-13-03
Location: UK
Posts: 2,819
Latest Blog: None
|
Quote:
|
Originally Posted by niceguyeddie
bah, it's netscape 4, so chances are it will only be seen once anyway 
|
LOL
is it really that bad!? (nevery botehred with nn4).
Sara do you expect a lot of your uses to be using NN4?
Why do you want to display a message to them?
|
|
|
12-04-2003, 03:07 PM
|
#12 (permalink)
|
|
Moderator
Join Date: 10-13-03
Location: UK
Posts: 2,819
Latest Blog: None
|
this reminds me of the The Web Standards Project's Browser Upgrade Campaign.
it used a bit of text at the beginning of the page that said "please upgrade your browser" type thing, and use CSS to hide that message for new browsers.
the message in the page:
[code:1:304dff9b9a]<p id="message">You browser is old, this page works and looks better on a standards complient browser. Please upgrade by <a href="...">clicking here</a>!</p>[/code:1:304dff9b9a]
and the CSS:
[code:1:304dff9b9a]<style>
/* load an external style sheet with the code to hide the browser upgrade paragraph */
@import "hide_message.css"
</style>
[/code:1:304dff9b9a]
NN4 does not support the @import command!
More detail and other tips for sniffing out browsers...
http://archive.webstandards.org/upgrade/tips.html
|
|
|
12-04-2003, 03:09 PM
|
#13 (permalink)
|
|
No Longer Here
Join Date: 09-27-03
Location: State College, PA
Posts: 9,354
Latest Blog: None
|
Quote:
|
Originally Posted by LazyJim
Sara do you expect a lot of your uses to be using NN4?
Why do you want to display a message to them?
|
It is for the ISP I work for. Many of our members (for some reason) still use N4. We can't get them to stop. I am redesigning our site and it looks like shit in N4, so I want to give them the message with a download link to N7.
|
|
|
12-04-2003, 03:10 PM
|
#14 (permalink)
|
|
Inactive
Join Date: 10-12-03
Location: Minnesota, USA
Posts: 2,207
Latest Blog: None
|
Quote:
|
Originally Posted by Jazzee
Quote:
|
Originally Posted by LazyJim
Sara do you expect a lot of your uses to be using NN4?
Why do you want to display a message to them?
|
It is for the ISP I work for. Many of our members (for some reason) still use N4. We can't get them to stop. I am redesigning our site and it looks like **** in N4, so I want to give them the message with a download link to N7.
|
Throw in a download link to Firebird while you're at it 
|
|
|
12-04-2003, 03:14 PM
|
#15 (permalink)
|
|
Moderator
Join Date: 10-13-03
Location: UK
Posts: 2,819
Latest Blog: None
|
good plan on getting them to upgrade
I would suggest you use the the CSS @import trick, but that means all non-desktop internet devices such as mobile phones would get the 'please upgrade' message, which is not wanted, and blind users would hear (or read o braile printer) "this site looks better on a more recent browser" !!!!
It depends on how limited your audience are (or could be).
which solution do u want to use?
|
|
|
12-04-2003, 03:15 PM
|
#16 (permalink)
|
|
No Longer Here
Join Date: 09-27-03
Location: State College, PA
Posts: 9,354
Latest Blog: None
|
I don't know. I am confused now
And nobody will be looking at the site on anything other than a desktop computer.
|
|
|
12-04-2003, 03:33 PM
|
#17 (permalink)
|
|
Moderator
Join Date: 10-13-03
Location: UK
Posts: 2,819
Latest Blog: None
|
in other words u have a known set of users and you know none require text-readers (i.e. blind people) and nobody (that matters) will access the site from other devices?
|
|
|
12-04-2003, 03:55 PM
|
#18 (permalink)
|
|
No Longer Here
Join Date: 09-27-03
Location: State College, PA
Posts: 9,354
Latest Blog: None
|
Right.
|
|
|
12-04-2003, 03:57 PM
|
#19 (permalink)
|
|
Possible Terrorist
Join Date: 10-13-03
Location: Tuscaloosa, AL or Atlanta
Posts: 4,904
|
mmh aight
i dont know how to do the popup part but if your doing php
[code:1:48ad716026]
<?php
if (!isset($_COOKIE['jazzeeAgain'])) {
?>
<script>
function checkbrowser()
{
//detect browser properties
var app = navigator.appName;
var ver = navigator.appVersion;
var agent = navigator.userAgent;
var code = navigator.appCodeName;
var plat = navigator.platform;
//detect netscape 4 browser
if ((agent.indexOf("4.")>-1) && (app=='Netscape'))
{
//open browser alert window
var
n=open('http://phpserver.kcnet.org/alert.html','browseralert','width=600,height=400,m enubar=no,scrollbars=yes,resizable=no,'
);
}
}
</script>
<?php
}
?>
[/code:1:48ad716026]
then on the alert page.. have the okay send it to a page with
[code:1:48ad716026]<?php
setcookie ("jazzeeAgain","1",0);
?>[/code:1:48ad716026]
__________________
Kyle Varga
"m3lt/theSpear"
student, web designer/coder, future IT consultant
Experience: PHP/MySQL, Java, C++, MS-SQL
|
|
|
12-04-2003, 04:01 PM
|
#20 (permalink)
|
|
No Longer Here
Join Date: 09-27-03
Location: State College, PA
Posts: 9,354
Latest Blog: None
|
But I want them to be able to click a button to never see the window again. I don't want it to automatically set a cookie. This way if they don't read the window and just close it, it will still pop up next time. It will keep popping up till they actually read it and tell it not to come up again.
|
|
|
|
Currently Active Users Viewing This Thread: 1 | |