-2

I'm wondering why isn't netscape working using JS

if(navigator.appName == "Netscape" && parseInt(navigator.appVersion.charAt(0)) >= 4){
  //netscape should work, but the code doesn't work and I get an error in the console
  netscape.security.PrivilegeManager.enablePrivilege("UniversalBrowserWrite");
  //uncaught ReferenceError: netscape is not defined
  window.open(
    "URL",
    "Name",
    "menubar=off, toolbar=off, location=off, personalbar=off, status=off, minimizable=off, resizable=off, directories=off, chrome=on, dialog=off, titlebar=no, alwaysRaised=on, close=no"
  );
}else{
  alert('Your browser isn\'t supported!');
}

All of the browsers (like Chrome, Firefox, Opera...) that work with Netscape return this error

Take note that the error is: uncaught ReferenceError: netscape is not defined

And for those who don't know what is Netscape, read this question's answer:

Why does JavaScript navigator.appName return Netscape for Safari, Firefox and Chrome?

EDIT:

New question, how can I get the UniversalBrowserWrite Privilege in Chrome, Firefox, Opera...?

1 Answers1

3

navigator.appName == "Netscape" is not a reliable test for support for the netscape object. Plenty of browsers set Netscape as the appName to work around terrible browser sniffing code. If you want to test for a feature, then test for the feature (e.g. if (typeof netscape !== 'undefined'),

In browsers which do support it (which I think is limited to Firefox), support for netscape.security.PrivilegeManager was removed many years ago for security reasons.

Quentin
  • 914,110
  • 126
  • 1,211
  • 1,335
  • Yeah, so how can I get the *UniversalBrowserWrite* Privilege in Chrome, Firefox, Opera...? – Shared Account Mar 13 '20 at 15:01
  • @SharedAccount — You can't. From the link: "You should find a workaround like an add-on where privileges are actually required." – Quentin Mar 13 '20 at 15:03
  • 1
    Thanks Quentin, you've ruined my weekend. The linked article made me remember all that again; ActiveX, JSSS, CSS Safety Lists ... – Teemu Mar 13 '20 at 15:13