调用autotoproxy(PAC)javascript with alert()?

前端之家收集整理的这篇文章主要介绍了调用autotoproxy(PAC)javascript with alert()?前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。
我正在编写一个用于Firefox的自定义.pac脚本.在我看到的很多例子之后,我插入了alert()来调试它,但没有警报弹出窗口,尽管脚本被清楚地被调用. (我在每次更改为脚本后,在“连接设置”中点击“重新加载”,甚至尝试重新启动Firefox.)

警报是否适用于PAC脚本?也许这是一个仅IE功能

解决方法

http://mxr.mozilla.org/mozilla-central/source/netwerk/base/src/nsProxyAutoConfig.js

警报功能添加到沙箱中:

80         // add predefined functions to pac
81         this._sandBox.importFunction(myIpAddress);
82         this._sandBox.importFunction(dnsResolve);
83         this._sandBox.importFunction(proxyAlert,"alert");

并且映射函数调用转储到错误控制台:

108 function proxyAlert(msg) {
109     msg = XPCSafeJSObjectWrapper(msg);
110     try {
111         // It would appear that the console service is threadsafe.
112         var cns = Components.classes["@mozilla.org/consoleservice;1"]
113                             .getService(Components.interfaces.nsIConsoleService);
114         cns.logStringMessage("PAC-alert: "+msg);
115     } catch (e) {
116         dump("PAC: proxyAlert ERROR: "+e+"\n");
117     }
原文链接:https://www.f2er.com/js/150463.html

猜你在找的JavaScript相关文章