Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

insertBefore method in VBScript

138 views
Skip to first unread message

Bob

unread,
Jun 13, 2004, 11:03:04 PM6/13/04
to
Can someone please explain: Why EXAMPLE 1 of JScript
works, but the EXAMPLE 2 of VBScript does not work?

Thanks,
Bob
/////////////////////////////
EXAMPLE 1:

<html>
<head>
<title>Sample code</title>
<script language="Jscript">

function testFunction() {

var x = document.createDocumentFragment();
var y = x.appendChild(document.createElement('h4'));
y.appendChild(document.createTextNode('Hello'));
var z = x.appendChild(document.createElement('p'));
z.appendChild(document.createTextNode('I am a document
fragment'));
var b = document.getElementById('writebefore');
b.parentNode.insertBefore(x,b);
}

</script>
</head>
<body onload="testFunction()">
<div id=writebefore></div>

</body>
</html>
/////////////////////////////

EXAMPLE 2:

<html>
<head>
<title>Sample code</title>
<script language="vbscript">

sub testSub()
dim x, y, z, b, c

set x = document.createDocumentFragment()
set y = x.appendChild(document.createElement("h4"))
y.appendChild document.createTextNode("Hello")
set z = x.appendChild(document.createElement("p"))
z.appendChild document.createTextNode("I am a document
fragment")
set b = document.getElementById("writebefore")
b.parentNode.insertBefore x,b
end sub

</script>
</head>
<body onload="testSub()">
<div id=writebefore></div>
</body>
</html>

Michael Harris (MVP)

unread,
Jun 14, 2004, 2:28:47 AM6/14/04
to
Bob wrote:
> Can someone please explain: Why EXAMPLE 1 of JScript
> works, but the EXAMPLE 2 of VBScript does not work?

Seems like a bug to me...

Wrapping the 2nd argument with ()s to force pass by value works...

b.parentNode.insertBefore x,(b)

--
Michael Harris
Microsoft.MVP.Scripting
Sammamish WA US

0 new messages