I copied the following script from MSDN. One thing I noticed right away is that the sub only works if placed *after* the html - why?
The other thing is, the only way I could get the call to the sub to work was by placing the call within the <Script> tag of the sub; if I placed [ChangeElementText "para2", "I am the new text in the second paragraph."] in its own <Script> tag, nothing happened. How can I call the sub from outside its own tags?
<BODY>
<CENTER>
<H1>
This is the heading on a simple page.
</H1>
</CENTER>
<P ID="para1">
This is the first paragraph on a simple page.
</P>
<P ID="para2">
This is the second paragraph on a simple page.
</P>
</BODY>
<Script Language = vbscript>
ChangeElementText "para2", "I am the new text in the second paragraph."
Sub ChangeElementText(strID, strNewText)
Dim objElement
Set objElement = document.all(strID)
If Len(objElement.innerText) > 0 Then
objElement.innerText = strNewText
End If
End Sub
</Script>
The other thing is, the only way I could get the call to the sub to work was by placing the call within the <Script> tag of the sub; if I placed [ChangeElementText "para2", "I am the new text in the second paragraph."] in its own <Script> tag, nothing happened. How can I call the sub from outside its own tags?
<BODY>
<CENTER>
<H1>
This is the heading on a simple page.
</H1>
</CENTER>
<P ID="para1">
This is the first paragraph on a simple page.
</P>
<P ID="para2">
This is the second paragraph on a simple page.
</P>
</BODY>
<Script Language = vbscript>
ChangeElementText "para2", "I am the new text in the second paragraph."
Sub ChangeElementText(strID, strNewText)
Dim objElement
Set objElement = document.all(strID)
If Len(objElement.innerText) > 0 Then
objElement.innerText = strNewText
End If
End Sub
</Script>