< Back

Document Subject: browser detection in javascript
Hint Short Cut: Add this to your code & documentation to help you find this page.
http://#BrowserType or http://A555F9/nn.nsf/ByAlias/BrowserType

Finding out the browser type. We used this to launch file attachments differently for ie and netscape.




Basically it is:

if (navigator.userAgent.indexOf('MSIE')==-1 ) {alert('netscape'); } else { alert('ie');};

if (navigator.userAgent.indexOf('MSIE')==-1 && navigator.userAgent.indexOf('Mozilla') >=0 ) {alert(' probably netscape'); } else { alert('ie');};

<a href=\'#\' onclick= \" alert (navigator.userAgent.indexOf('MSIE')); if (navigator.userAgent.indexOf('MSIE')==-1) { popup = window.open(\'http://server/db.nsf/WebIntranetDocs/"+
@Text(@DocumentUniqueID)+"\',\'"+@ReplaceSubstring(Title;" ":"\'":"\"""_")+"\',\'toolbar=0,location=0,directories=0,status=0,menubar=0,scrollbars=no,resizable=yes,width=300,height=250\');} else {popup = window.open(\'http://server/db.nsf/WebIntranetDocs/"+
@Text(@DocumentUniqueID)+"/$File/"+@ReplaceSubstring(@Subset(@AttachmentNames;1);" ":"\'":"\"""_")+"\',\'"+@ReplaceSubstring(Title;" ":"\'":"\"""_")+"\',\'toolbar=0,location=0,directories=0,status=0,menubar=0,scrollbars=no,resizable=yes,width=300,height=250\');} ; return false;\">"+Title+" </a>