- 檔案系統模組
- 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
廣告