- iOS/Objective-C 元类和类别
- objective-c - -1001 错误,当 NSURLSession 通过 httpproxy 和/etc/hosts
- java - 使用网络类获取 url 地址
- ios - 推送通知中不播放声音
我正在尝试使用 electron 创建网站的独立版本,我有这个 main.js(摘录)
function createWindow() {
// Create the browser window.
mainWindow = new BrowserWindow({
width: 800,
height: 600,
"min-width": 800,
"min-height": 500,
resize: true,
"use-content-size": true
});
// and load the index.html of the app.
mainWindow.loadURL('file://' + __dirname + '/index.html');
// Open the DevTools.
mainWindow.webContents.openDevTools();
// Set Window Resizable
mainWindow.isResizable(true);
// Emitted when the window is closed.
mainWindow.on('closed', function () {
// Dereference the window object, usually you would store windows
// in an array if your app supports multi windows, this is the time
// when you should delete the corresponding element.
mainWindow = null;
});
}
然后 index.html 看起来像这样:
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title></title>
<style>
body {
margin: 0;
padding: 0;
background-color: #6e6e6e;
}
webview {
display: block;
}
</style>
</head>
<body>
<webview src="build/index.html" disablewebsecurity></webview>
</body>
</html>
不幸的是,内容(webview)没有调整大小以填充可用空间,它具有全宽但高度保持在 150px,当我在检查器面板中手动设置不同的大小然后它会调整。我如何告诉 webview 它应该占用全部空间?百分比不起作用,即。
webview {
width:100%;
height:100%;
}
我已将以下代码添加到 index.html
<script>
function onResize() {
var height = document.body.clientHeight;
var width = document.body.clientWidth;
console.log("onResize", arguments, width, height);
}
addEventListener('resize', onResize);
</script>
输出以下结果(高度始终为 150!)
onResize [Event] 216 150
index.html:27 onResize [Event] 216 150
index.html:27 onResize [Event] 1096 150
index.html:27 onResize [Event] 1096 150
index.html:27 onResize [Event] 1096 150
index.html:27 onResize [Event] 1080 150
0: Event
bubbles: true
cancelBubble: false
cancelable: false
currentTarget: null
defaultPrevented: fals
eeventPhase: 0
isTrusted: false
isTrusted: false
newHeight: 150
newWidth: 1080
path: Array[5]
returnValue: true
srcElement: webview
target: webview
timeStamp: 1453905541457
type: "resize"__proto__: Event
callee: onResize()
length: 1
Symbol(Symbol.iterator): values()
__proto__: Object
最佳答案
您已将 webview
的高度设置为 100%
,但没有为父级设置明确的高度(在本例中为 body
)。提供 body
和明确的大小应该可以解决您的问题:
body {
width: 100vw;
height: 100vh;
}
另见:
关于javascript - 内容(webview)没有填满应用程序窗口,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35039240/
Webview shouldInterceptRequest方法总是返回null。我去了adblocking的use方法。我尝试了很多adblock方法,但是总是需要这个shouldIntercept
在我的 Native React 项目中,我想使用 WebView。 HTML是指外部的css文件,css文件是指一些自定义字体。 鉴于此层次结构: app/ app/index.ios.js app
我在一个页面上有多个 webview,当应用程序加载时,主页面卡住了将近 8-10 秒,我猜测这是所有 webview 加载各自网站所花费的时间,为什么 Ui 卡住了,我怎么能使 webview 加载
nativescript 中的 webview 是否有“导航”事件? 我已经在 Xamarin (c#) 中用 完成了 Browser.Navigating += Myfunction natives
我的浏览器 (webview) 以 HTML 页面开头 FILEJAVA.class.getResource ("FILEHTML.html")。 ToExternalForm () 每当我访问谷歌时
我们正在开发一个 JavaFX 2.x 应用程序,它需要提供一些 GIS 支持。我们得出的结论是,通过嵌入式 WebView 使用 GoogleMaps 是最快的选择。它的问题在于每次我们的应用程序启
有没有办法销毁 WebView 实例?如果页面加载,并说视频开始播放,我希望能够,当我隐藏 WebView 时,基本上可以销毁它,或者至少重置它。 我知道我可以听 visibleProperty 并执
有没有办法在不启用远程模块的情况下在 webview 和主窗口之间进行通信? When this attribute is false the guest page in webview will
我使用以下代码来拦截Web View 中的对话框,但看不到内容或无法与之交互: Element webview= querySelector("#webview"); Map map=new
我正在创建一个页面,该页面将在 Java 的 WebView 中打开,或在外部浏览器中手动打开。如果页面是从 Java 加载的——我需要它来执行特定的回调,因为 Java 被用作一种后端,但如果页面是
我有一个 React Native WebView ,它运行一个小的 HTML 文档。该文档显示了一些图像。 我希望显示位于应用程序的 Documents 文件夹中的图像,即图像不是静态 Assets
我正在使用 JavaFX webview 开发一个网络爬虫。出于抓取目的,我不需要加载图像。当页面被加载时,Webkit 会产生很多 UrlLoader 线程。所以我认为最好禁用图像,这样我会节省很多
这个问题在这里已经有了答案: Android webview launches browser when calling loadurl (11 个答案) 关闭 7 年前。 我花了两天的时间来寻找一
我正在加载一个网页,我想使用基本身份验证登录,我有使用 Swift 的经验并且能够像下面那样执行基本身份验证,但我无法为我的应用程序的 Flutter 版本实现基本身份验证。 ---- swift 代
我用 webview 创建了应用程序,我想在 webview 中加载所有内部链接并在 android 浏览器中加载外部链接。现在的问题是我正在使用 html 广告,当我点击广告时我想打开外部浏览器,但
我需要在父背景图案上显示我的 webview 内容。有没有直接的方法来做到这一点? 最佳答案 这可能有用 final com.sun.webkit.WebPage webPage = com.sun.
是否可以从 webview 中加载的页面读取 http 请求和响应数据。我想要做的是在用户单击 webview 中页面内的链接后从响应中获取二进制数据。任何帮助或线索将不胜感激 最佳答案 创建您自己的
我有一个简单的WebView在 Android 上运行 Web 应用程序。问题是当我旋转手机以将其更改为横向 webview重新加载并回到开头。 我怎样才能防止这种行为? 罗恩 最佳答案 从 Andr
我创建了一个带有 webview 标签的自定义浏览器。当我在 google.it(或 google.com)中导航时,有时会出现一条消息说 chrome 已过时。我的应用版本是: Node.js 8.
我正在使用 Electron 创建简单的网络浏览器。我的用例是我需要通过不同/各自的代理 IP 路由每个 URL。如果用户输入 google.com,则必须通过 123.123.122.1:8081
我是一名优秀的程序员,十分优秀!