electron webview模拟手机phone屏幕
electron webview simulate mobile phone screen
我正在制作一个电子桌面应用程序,试图模拟 google 设备工具栏,如果我使用 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
}
我正在制作一个电子桌面应用程序,试图模拟 google 设备工具栏,如果我使用 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
}