Home  >  Article  >  Web Front-end  >  nw.js 如何禁用向主窗口拖放文件?

nw.js 如何禁用向主窗口拖放文件?

WBOY
WBOYOriginal
2016-06-07 08:43:061751browse

由于主界面其实就是 Chrome 的浏览器窗口,所以沿袭了它的一些行为,例如将外部文件拖进窗口时,node-webkit 会尝试打开文件比如如果文件是图片,那么主窗口就会直接显示出这张图片,如果不禁用这个行为的话实在太容易穿帮了。

回复内容:

著作权归作者所有。
商业转载请联系作者获得授权,非商业转载请注明出处。
作者:玄魂
链接:zhuanlan.zhihu.com/xuan
来源:知乎

其实拖放(drag-drop)操作是Html5的功能,不是nw.js的内置API,那么我们采用Html5应用一般的处理方法就可以了。

首先我们看一下一个正常的页面,直接拖放一个文件过来的效果。

页面代码:


<code class="language-text">
  
  <title>拖放测试</title> 
  
 
  <bodystyle> 
   <pid> 
    <h1>拖放测试</h1> 
    <p></p> 
    <script>

</script>  
   </pid>="output">
  </bodystyle>="background-color:rgba(0,0,0,0);">
 

</code>
Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn