PhantomJS - switchToMainFrame() 方法

switchToMainFrame() 方法选择主框架,即根窗口。

语法

其语法如下 −

var wpage = require('webpage').create();
wpage.switchToMainFrame();

示例

var page = require('webpage').create(); 
page.open('http://localhost/tasks/frames.html', function(status) { 
   page.switchToMainFrame(); 
   console.log(page.frameName); 
});

它将产生以下输出

page2

phantomjs_webpage_module_methods.html