[英]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.