getWebviewById( )

MUI HTML5

MUI

getWebviewById( )

查找指定标识的WebviewObject窗口


WebviewObject plus.webview.getWebviewById( id );
				

说明:

在已创建的窗口列表中查找指定标识的Webview窗口并返回。 若没有查找到指定标识的窗口则返回null,若存在多个相同标识的Webview窗口,则返回第一个创建的Webview窗口。 如果要获取应用入口页面所属的Webview窗口,其标识为应用的%APPID%,可通过plus.runtime.appid获取。

参数:

  • id: ( String ) 必选 要查找的Webview窗口标识

返回值:

WebviewObject : WebviewObject窗口对象

示例:


<!DOCTYPE html>
<html>
	<head>
	<meta charset="utf-8">
	<title>Webview Example</title>
	<script type="text/javascript">
// H5 plus事件处理
function plusReady(){
	// 查找应用首页窗口对象
	var h=plus.webview.getWebviewById( plus.runtime.appid );
	console.log( "应用首页Webview窗口:"+h.getURL() );
}
if(window.plus){
	plusReady();
}else{
	document.addEventListener("plusready",plusReady,false);
}
	</script>
	</head>
	<body>
		查找指定标识的窗口
	</body>
</html>