setJsFile( )

MUI HTML5

MUI

setJsFile( )

设置预加载的JS文件


void wobj.setJsFile( path );
						

说明:

预加载JS文件不需要在HTML页面中显式引用,在Webview窗口加载HTML页面时自动加载,在页面跳转时也会自动加载。 设置新的JS文件后将清空之前设置的值。

参数:

  • file: ( String ) 必选 预载入的JS文件地址,仅支持本地文件,格式为相对路径URL(plus.io.RelativeURL),如"_www/preload.js"

返回值:

void : 无

示例:


<!DOCTYPE html>
<html>
	<head>
	<meta charset="utf-8">
	<title>Webview Example</title>
	<script type="text/javascript">
var ws=null,embed=null;
// H5 plus事件处理
function plusReady(){
	ws=plus.webview.currentWebview();
	embed=plus.webview.create("http://weibo.com/dhnetwork","",{top:"46px",bottom:"0px"});
	embed.setJsFile( "_www/js/preload.js" );
	ws.append(embed);
}
if(window.plus){
	plusReady();
}else{
	document.addEventListener("plusready",plusReady,false);
}
	</script>
	</head>
	<body>
		设置预加载的JS文件
	</body>
</html>