- 文件系统模块
- PhantomJS - 属性
- PhantomJS - 方法
- 系统模块
- PhantomJS - 属性
- 网络服务器模块
- PhantomJS - 属性
- PhantomJS - 方法
- 杂项
- 命令行界面
- PhantomJS - 屏幕截图
- PhantomJS - 网页自动化
- PhantomJS - 网络监控
- PhantomJS - 测试
- PhantomJS - REPL
- PhantomJS - 示例
- PhantomJS 有用资源
- PhantomJS - 快速指南
- PhantomJS - 有用资源
- PhantomJS - 讨论
PhantomJS - ownsPages 属性
ownsPages 属性检查由网页打开的页面是否为子页面。它会根据情况返回 true 或 false。
语法
语法如下:
var wpage = require('webpage').create();
wpage.ownsPages
示例
举例说明如何使用 ownsPages 属性。
var wpage = require('webpage').create();
wpage.open('https:///tasks/page1.html', function (status) {
console.log(wpage.ownsPages);
phantom.exit();
});
page1.html
<html>
<head>
<title>Testing PhantomJs</title>
</head>
<body>
<script type = "text/javascript">
console.log('welcome to cookie example');
document.cookie = "username = Roy; expires = Thu, 22 Dec 2017 12:00:00 UTC";
window.onload = function() {
console.log("page is loaded");
window.open("https:///tasks/a.html","page1");
}
</script>
<h1>This is a test page</h1>
</body>
</html>
以上程序会生成以下 输出。
True
phantomjs_webpage_module_properties.htm
广告