转:
参考的一个文档的地址:
http://www.softwareinquisition.com/81.htm
Dim newObj
Set newObj = Browser("**").Page("**").Object.createElement("Div")
'newObj.innertext = "试试"
newObj.id = "idtest"
Browser("**").Page("**").Object.body.appendChild newObj
'动态加载JS脚本
Dim objHead,objScript
Set bjHead = Browser("**").Page("**").Object.getElementsByTagName("HEAD").item(0)
Set bjScript. = Browser("*").Page("*").Object.createElement( "script" )
objScript.language = "javascript"
objScript.type = "text/javascript"
objScript.id = "sIdTest"
objScript.defer = true
objScript.text = "function aaa(){alert(""测试一下"");} document.getElementById('idtest').onclick=aaa "
objHead.appendChild( objScript. )
newObj.fireEvent "onclick"
————————————————————————
**********************************8
以上的方法都是说需要特殊处理的情况,如果说只是执行已有JS函数或都JS脚本,那只要用以下方法即可:
Dim objHead,objScript
Set bjHead = Browser("**").Page("**").Object.getElementsByTagName("HEAD").item(0)
Set bjScript. = Browser("**").Page("**").Object.createElement( "script" )
objScript.language = "javascript"
objScript.type = "text/javascript"
objScript.id = "sIdTest"
objScript.defer = true
objScript.text = "JS脚本或JS函数名"
objHead.appendChild( objScript. )