简体   繁体   English

Javascript是否可以从浏览器外部进行选择?

[英]Can Javascript get a selection from outside the browser?

How can a Javascript script running within a browser obtain a window system selection from a region outside the browser? 在浏览器中运行的Javascript脚本如何从浏览器外部的区域中获取窗口系统选择? For example, in scan mode, StarDict, a Java program not running in a browser, responds to a selection event in, say, an xterm or pdf viewer, by looking up the selected text. 例如,在扫描模式下,StarDict(一种不在浏览器中运行的Java程序)通过查找所选文本来响应xterm或pdf查看器中的选择事件。 How can a Javascript program running in a browser respond similarly? 浏览器中运行的Javascript程序如何做出类似响应? As far as I can tell, everything having to do with selection in Javascript is with respect to the DOM and therefore internal to the browser. 据我所知,与Java语言选择有关的一切都与DOM有关,因此是浏览器内部的。

The short answer is you can't. 简短的答案是你不能。

The slightly longer answer is you could write a browser extension that interacts with the system outside the sandbox and use that to communicate with your page. 稍长一点的答案是,您可以编写一个浏览器扩展,与沙箱外部的系统进行交互,并使用该扩展与您的页面进行通信。 But you then have the trouble of getting your users to install your extension and convince them that is isn't a huge security risk. 但是,这样一来,您就很难让用户安装扩展程序,并说服他们这不是很大的安全风险。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 我可以从文本或textarea之外的文本选择中获取Javascript事件吗? - Can I get a Javascript event from the selection of text outside of text or textarea? Javascript:我可以获取选择的文本,现在如何获取选择之外的文本? - Javascript: I can get the text of a selection, now how do I get the text outside the selection? 如何获取可以在浏览器外部传递的JavaScript中的对象(COM)的引用 - How to get a reference to an object (COM) in JavaScript that can be passed outside the browser 如何从JavaScript的选择框中获取价值? - How can i get value from selection box in javascript? 如何从核心javascript选择中获取jquery元素? - How can i get jquery element from the core javascript selection? 从OUTSIDE浏览器调用Javascript函数? - call Javascript function from OUTSIDE the browser? 我们如何用Java编写脚本/自动化firebug-> Profile JavaScript,以便可以从浏览器外部运行它? - How can we script/automate firebug --> Profile JavaScript, in Java so it can be run from outside the browser? 如何使用php / javascript从用户浏览器中获取突出显示/选择的数据? - how to get highlighted/selection data from a users browser using php/javascript? 跨浏览器 javascript 从用户的选择中获取和替换准确的 HTML? - Cross-browser javascript to get and replace exact HTML from a user's selection? 在浏览器之外解释JavaScript? - Interpreting JavaScript outside of the browser?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM