html - electron webview 模拟手机屏幕

标签 html iframe webview electron embed

我正在制作一个 Electron 桌面应用程序,试图模拟谷歌设备工具栏,如果我使用 iframe,我会得到所需的行为,网页填满整个屏幕,(没有水平滚动条),但是我不能嵌入具有相同来源的网站策略,另一方面,webview 可以显示这些网站,但我无法模拟设备的高度和宽度,对于较小的设备,只有部分网页可见,您必须水平滚动才能看到页面。有没有办法解决 ?

最佳答案

有点晚了,但这里有一个解决方案(如果我理解正确?):

<webview src="https://instagram.com/direct/inbox" useragent="Mozilla/5.0 (Linux; Android 4.2.1; en-us; Nexus 5 Build/JOP40D) AppleWebKit/535.19 (KHTML, like Gecko; googleweblight) Chrome/38.0.1025.166 Mobile Safari/535.19"></webview>

或者
const webview = document.querySelector('webview')

webview.useragent = "Mozilla/5.0 (Linux; Android 4.2.1; en-us; Nexus 5 Build/JOP40D) AppleWebKit/535.19 (KHTML, like Gecko; googleweblight) Chrome/38.0.1025.166 Mobile Safari/535.19"
webview.src = 'https://instagram.com/direct/inbox'

额外信息:

Electron useragent
List of User Agents

确保您使用 webviewTag

webPreferences: {
  nodeIntegration: true,
  webviewTag: true
}

关于html - electron webview 模拟手机屏幕,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/59040019/

相关文章:

html - 为什么 iframe 高度 100% 在 XHTML 页面中不起作用?

google-maps - 从Google Maps Embed iframe删除黑色标题

android - Webview 应用程序中的 Google 和 Facebook 登录 (OAuth)(需要覆盖弹出功能吗?)

c# - DoubleTapped 事件在 WebView 上不起作用

c# - UIWebView 中的 Windows 身份验证 url 没有响应,没有错误,请求无限期旋转 - Xamarin.iOS

html - h6 元素占用的空间超出了应有的空间

html - SVG 元素在 Chrome 浏览器中居中对齐,但它应该向右对齐

javascript - 获取鼠标移动速度

html - 自动调整 div 容器内子 div 的高度

php - 更改 iFrame SRC 并在数据库内容更改时重新加载 iFrame