久久久久久久av_日韩在线中文_看一级毛片视频_日本精品二区_成人深夜福利视频_武道仙尊动漫在线观看

如何訪問 <webview> 的 DOM在電子?

How can I access the DOM of a lt;webviewgt; in Electron?(如何訪問 lt;webviewgt; 的 DOM在電子?)
本文介紹了如何訪問 <webview> 的 DOM在電子?的處理方法,對大家解決問題具有一定的參考價值,需要的朋友們下面隨著小編來一起學習吧!

問題描述

我剛剛開始使用 Electron,之前有使用 node-webkit (nw.js) 的經驗.

I'm just getting started with Electron, with prior experience with node-webkit (nw.js).

在 nw.js 中,我能夠創建 iframe,然后訪問所述 iframe 的 DOM,以獲取標題、favicon 等內容.幾天前,當我拿起 Electron 將我的 nw.js 應用程序移植到它時,我看到了使用 webviews 而不是 iframes 的建議,僅僅是因為它們更好.現在,我上面提到的功能在 nw.js 中相對容易實現,但我不知道如何在 Electron 中實現(示例很少).有人可以幫忙嗎?

In nw.js, I was able to create iframes and then access the DOM of said iframe in order to grab things like the title, favicon, &c. When I picked up Electron a few days ago to port my nw.js app to it, I saw advice to use webviews instead of iframes, simply because they were better. Now, the functionality I mentioned above was relatively easy to do in nw.js, but I don't know how to do it in Electron (and examples are slim to none). Can anyone help?

另外,我的 webview 有后退/前進按鈕(我打算有多個).我在文檔中看到我可以在 webview 上調用函數來執行此操作,但我嘗試過的也沒有任何效果(而且,我還沒有找到在野外使用它們的示例).

Also, I have back/forward buttons for my webview (and I intend on having more than one). I saw in the documentation that I could call functions for doing so on a webview, but nothing I have tried worked either (and, I haven't found examples of them being used in the wild).

推薦答案

除了 guest 以 NetOperatorWibby,從主人到客人也非常有用.目前唯一的方法是使用 <webview>.executeJavaScript(code, userGesture).這個 api 有點粗,但是可以.

Besides guest to host IPC calls as NetOperatorWibby, it is also very useful to go from host to guest. The only way to do this at present is to use the <webview>.executeJavaScript(code, userGesture). This api is a bit crude but it works.

如果您正在使用遠程訪客,例如擴展"第三方網頁,您還可以使用 webview preload 屬性,它會在頁面上運行任何其他腳本之前執行您的自定義腳本.請注意,出于安全原因,preload api 將在您的自定義腳本完成時核對在自定義 JS 文件的根命名空間中創建的任何函數,但是此托管過程不會核對您在根中聲明的任何對象.因此,如果您希望自定義函數保持不變,請將它們捆綁到一個單例對象中,您的自定義 API 將在頁面完全加載后保持不變.

If you are working with a remote guest, like "extending" a third party web page, you can also utilize webview preload attribute which executes your custom script before any other scripts are run on the page. Just note that the preload api, for security reasons, will nuke any functions that are created in the root namespace of your custom JS file when your custom script finishes, however this custodial process will not nuke any objects you declare in the root. So if you want your custom functions to persist, bundle them into a singleton object and your custom APIs will persist after the page fully loads.

[update] 這是一個我剛剛寫完的簡單示例:Electron-Webview-Host-to-Guest-RPC-Sample

[update] Here is a simple example that I just finished writing: Electron-Webview-Host-to-Guest-RPC-Sample

這篇關于如何訪問 &lt;webview&gt; 的 DOM在電子?的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網!

【網站聲明】本站部分內容來源于互聯網,旨在幫助大家更快的解決問題,如果有圖片或者內容侵犯了您的權益,請聯系我們刪除處理,感謝您的支持!

相關文檔推薦

discord.js v12: How do I await for messages in a DM channel?(discord.js v12:我如何等待 DM 頻道中的消息?)
how to make my bot mention the person who gave that bot command(如何讓我的機器人提及發出該機器人命令的人)
How to fix Must use import to load ES Module discord.js(如何修復必須使用導入來加載 ES 模塊 discord.js)
How to list all members from a specific server?(如何列出來自特定服務器的所有成員?)
Discord bot: Fix ‘FFMPEG not found’(Discord bot:修復“找不到 FFMPEG)
Welcome message when joining discord Server using discord.js(使用 discord.js 加入 discord 服務器時的歡迎消息)
主站蜘蛛池模板: 欧美视频一区二区三区 | 亚洲一级大片 | 日韩欧美在线播放 | 触手繁殖の地狱3d啪啪 | 欧美福利视频 | 亚洲激情一区二区 | 97视频免费| 久久九九99| 久久精品伊人 | 亚洲激情综合网 | 高潮毛片又色又爽免费 | 伊人国产女 | 黄色片网站在线观看 | 激情综合婷婷 | 成人免费看| 黄色片观看 | 日韩中文字幕在线观看 | 精品乱子伦一区二区三区 | 欧美一级做性受免费大片免费 | 欧美精品99久久久 | 欧美综合久久 | 国产日韩欧美一区 | 青青在线 | 日韩欧美精品一区二区 | 日本毛片在线观看 | 国产午夜三级 | 欧美久久一区 | 伊人久久精品视频 | 亚洲香蕉视频 | 在线a视频 | 亚洲视频色 | 午夜视频在线 | 一级特黄妇女高潮 | 欧美黑人一区二区三区 | 精品国产乱码久久久久久88av | 六月婷婷激情 | 欧美日韩免费看 | 久久久久女人精品毛片九一 | 欧美性视频在线 | 欧美精品久久久久久久 | 亚洲经典一区二区 |