Secret copy to clipboard JavaScript function in Chrome and Firefox?(Chrome和Firefox中的秘密复制到剪贴板JavaScript功能?)
问题描述
更新
看起来 还定义了一个函数列表:
this.clear = function()//没有网页交互{Firebug.Console.clear(context);};this.inspect = function(obj, panelName)//没有网页交互{Firebug.chrome.select(obj, panelName);};this.keys = 函数(o){返回 FBL.keys(o);//对象来自页面,未包装};this.values = 函数(o){返回 FBL.values(o);//对象来自页面,未包装};//等等...
Update
Looks like browsers are starting to support copy natively in JS
In the console windows of both Chrome and Firefox on Mac I can execute
copy("party in your clipboard!");
and the text gets copied to my clipboard. I have searched SO and Google and can't seem to find anything on this.
- Are these specific to each browser?
- Where can I find more information on these JavaScript functions?
Browser versions:
JavaScript returned from Chrome console when executing 'copy'
function (object)
{
if (injectedScript._type(object) === "node") {
var nodeId = InjectedScriptHost.pushNodePathToFrontend(object, false, false);
InjectedScriptHost.copyNode(nodeId);
} else
InjectedScriptHost.copyText(object);
}
- What does this code mean?
Here are 2 screenshots of executing copy function in Chrome console with all chrome extensions disabled
I believe these are predefined Firebug console functions - at least that seems to be the case for Firebug. If you try calling window.copy
for instance, you'll get a warning about function not defined, so it's definitely not a browser function, and cannot be used in normal JavaScript files. The following functions also seems to work in the JavaScript console, after playing around with it a bit:
clear()
profile()
Running these in the Chrome console reveals the source behind these functions in the Webkit console:
> profile
function ()
{
return console.profile.apply(console, arguments)
}
> clear
function ()
{
InjectedScriptHost.clearConsoleMessages();
}
> copy
function (object)
{
if (injectedScript._type(object) === "node")
object = object.outerHTML;
InjectedScriptHost.copyText(object);
}
While the Firebug source also defines a list of functions:
this.clear = function() // no web page interaction
{
Firebug.Console.clear(context);
};
this.inspect = function(obj, panelName) // no web page interaction
{
Firebug.chrome.select(obj, panelName);
};
this.keys = function(o)
{
return FBL.keys(o); // the object is from the page, unwrapped
};
this.values = function(o)
{
return FBL.values(o); // the object is from the page, unwrapped
};
// etc...
这篇关于Chrome和Firefox中的秘密复制到剪贴板JavaScript功能?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:Chrome和Firefox中的秘密复制到剪贴板JavaScript功能?
基础教程推荐
- Electron 将 Node.js 和 Chromium 上下文结合起来意味着 2022-01-01
- Vue 3 – <过渡>渲染不能动画的非元素根节点 2022-01-01
- html表格如何通过更改悬停边框来突出显示列? 2022-01-01
- 我可以在浏览器中与Babel一起使用ES模块,而不捆绑我的代码吗? 2022-01-01
- 如何使用JIT在顺风css中使用布局变体? 2022-01-01
- Chart.js 在线性图表上拖动点 2022-01-01
- 如何使用TypeScrip将固定承诺数组中的项设置为可选 2022-01-01
- 用于 Twitter 小部件宽度的 HTML/CSS 2022-01-01
- 自定义 XMLHttpRequest.prototype.open 2022-01-01
- 直接将值设置为滑块 2022-01-01