5

第07课:使用 HTML 5 API 创建子窗口

 3 years ago
source link: https://blog.csdn.net/nokiaguy/article/details/108729651
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.
neoserver,ios ssh client

在 Electron 中还存在一种创建窗口的方式,就是使用 HTML 5 的 API 创建窗口。在 HTML 5 中提供了 window.open 方法用于打开一个子窗口,该方法返回一个 BrowserWindowProxy 对象,并且打开了一个功能受限的窗口。

window.open 方法的原型如下。

window.open(url[, title] [,attributes)

参数的说明如下。

(1)url:要打开页面的链接(包括本地页面路径和 Web 链接)。

(2)title:设置要打开页面的标题,如果在要打开页面中已经设置了标题,那么这个参数将被忽略。

(3)attributes:可以设置与窗口相关的一些属性,如窗口的宽度和高度,其中第 1 个参数是必选的,第 2 个和第 3 个参数是可选的。

7.1 用 open 方法创建一个功能受限的子窗口

使用该方法打开一个本地页面的代码如下。

运行上面的代码,会看到如下图的效果。

1240

使用该方法打开一个 Web 页面的代码如下。


About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK