有人知道上述函数的源代码吗?仅供引用,它是在 Firefox 浏览器中实现功能“将链接另存为..”的功能。
最佳答案
DXR和 MXR是您的 friend (除了获取代码;毕竟它是开源的)。
搜索 saveLink
后:
- > http://dxr.mozilla.org/mozilla-central/source/browser/base/content/nsContextMenu.js#1255
- > http://mxr.mozilla.org/mozilla-central/source/browser/base/content/nsContextMenu.js#1255
- Mercurial 引用:http://hg.mozilla.org/mozilla-central/file/e743fd8c57ed/browser/base/content/nsContextMenu.js#l1255
另外,在 a browser context scratchpad :
console.log(nsContextMenu.prototype.saveLink.toSource());
结果
"(function () {
var doc = this.target.ownerDocument;
var linkText;
// If selected text is found to match valid URL pattern.
if (this.onPlainTextLink)
linkText = this.focusedWindow.getSelection().toString().trim();
else
linkText = this.linkText();
urlSecurityCheck(this.linkURL, this._unremotePrincipal(doc.nodePrincipal));
this.saveHelper(this.linkURL, linkText, null, true, doc);
})"
等等...(虽然,您需要知道 gContextMenu
是 nsContextMenu
的一个实例,您可以在 MXR 中找到它,.. .)
关于javascript - Firefox 中的 gContextMenu.saveLink() 函数,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24859458/