110,566
社区成员
发帖
与我相关
我的任务
分享
webbrowser加载外部html文件和外部js文件,代码示例:
webBrowser1.Navigate(@"c:\test.htm");
外部html文件代码:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html>
<head>
<title></title>
<script type="text/javascript" src="JScript1.js"></script>
</head>
<body onload="addHello()">
</body>
</html>
外部js文件代码:
function addHello(){
var bgObj=document.createElement("div");
bgObj.setAttribute('id','bgDiv');
bgObj.style.border="1px solid #333";
bgObj.innerHTML="this is text from js file!";
document.body.appendChild(bgObj);
}