Click to See Complete Forum and Search --> : OnClick "Check browser" and then pop up window
vmarasigan
12-10-2002, 05:25 PM
I would like a Check Browser script to be activated when a user hits a button on a page. If the user has Netscape/IE 4.0 or earlier, a new window would pop up, saying "Our site has detected that you are using an older version of Netscape.
Older versions of Netscape cause our site to run slowly...BLAH BLAH BLAH."
I have found many "check browser" and "open new browser window" scripts (Dreamweaver has both), but I have no idea if there is a way to associate them.
Any help for this novice would be appreciated!!
Zach Elfers
12-10-2002, 09:03 PM
<script language="JavaScript">
function Browsers() {
newWin = window.open("","","height=100;width=100");
newWin.focus();
if (navigator.appName == "Netscape" && navigator.appVersion > 4) {
newWin.document.write("You have a newer version of Netscape");
}
else {
newWin.document.write("Our site has detected that you are using an older version of Netscape.
Older versions of Netscape cause our site to run slowly...BLAH BLAH BLAH.");
}
return true;
}
</script>
<form>
<input type="button" value="Browser Check" onClick="Browsers();">
</form>
I hope that is what you want.:)
vmarasigan
12-11-2002, 07:32 AM
Thanks Zach, but I tried it out and it doesn't work:
http://www.yourpersonaltouch.net/checkbrowser.html
I get the following javascript errors:
Line 26: Browsers is not defined
Line 15: Unterminated string literal
What am I doing wrong?
A SIDENOTE: Can the script be adapted so that the new window automatically appears when the page loads?
Thanks again for your help!!
vmarasigan
12-11-2002, 09:31 AM
This is an onLoad version I was able to come with, but how do I control the size of the pop-up window (newURL)?
See it in action here: http://www.advp.com/checkbrowsertest_alt2.html
<script language="JavaScript">
<!--
function MM_checkBrowser(NSvers,NSpass,NSnoPass,IEvers,IEpass,IEnoPass,OBpass,URL,altURL) { //v4.0
var newURL='', verStr=navigator.appVersion, app=navigator.appName, version = parseFloat(verStr);
if (app.indexOf('Netscape') != -1) {
if (version >= NSvers) {if (NSpass>0) newURL=(NSpass==1)?URL:altURL;}
else {if (NSnoPass>0) newURL=(NSnoPass==1)?URL:altURL;}
} else if (app.indexOf('Microsoft') != -1) {
if (version >= IEvers || verStr.indexOf(IEvers) != -1)
{if (IEpass>0) newURL=(IEpass==1)?URL:altURL;}
else {if (IEnoPass>0) newURL=(IEnoPass==1)?URL:altURL;}
} else if (OBpass>0) newURL=(OBpass==1)?URL:altURL;
if (newURL) { window.open(newURL); document.MM_returnValue=false; }
}
//-->
</script>
<body>
<img src="spacer.gif" width="72" height="72" onLoad="MM_checkBrowser(5.0,0,1,4.0,0,0,0,'checkbrowsertest2.html','');return document.MM_returnValue
</body>