Hi all,
I searched the forums and was not able to come up with an answer to my post. I hope someone can help.
When IE8 launched inPrivateBrowsing, they made code available to detect its use:
I need to find a similar piece of code that will detect private browsing mode for Firefox 3.5. I thought I had found a solution on developer.mozilla, but I can't make it work.Code:if (navigator.userAgent.indexOf("MSIE")>-1) { if (window != 0) { if (typeof window.external != "undefined") { try { if (window.external.InPrivateFilteringEnabled() == true) { var isMSIEinPrivate=true; } } catch(e){ } } } }
This always alerts Error Trapped when I view it in Firefox, even in 3.5 with Private Browsing mode turned on. Is there a solution via javascript to detect this browsing mode in Firefox?Code:if (navigator.userAgent.indexOf("Firefox")>-1) { try { var pbs = Components.classes["@mozilla.org/privatebrowsing;1"] .getService(Components.interfaces.nsIPrivateBrowsingService); var inPrivateBrowsingMode = pbs.privateBrowsingEnabled; if (inPrivateBrowsingMode) { var isFFXPrivate=true; } } catch(e){ alert("Error Trapped!"); } }
Thank you in advance for your help.
-- Richard



Reply With Quote
Bookmarks