...

View Full Version : VBScript&JScript



wind0965
01-16-2004, 03:57 PM
I have viewed some examples, they use more than one scripts, that is use <script language="Javascript" type="text/javascript">
... ... </script> block more than once. Why use that? And the global variables are valid in the whole page or only inside one block?
Another question is: can I use both VBscript and JScript in one page. How can the variables be transfered between the two ones.

Thank you!

Danne
01-16-2004, 07:26 PM
Global variables are available on the whole page regardless if it's vbs or js, as far as I know.

To communicate from VBScript to JavaScript you can use the "call" in VBS:


<html>
<head>
<title> </title>
</head>
<script>

var global = "created in js\n";

</script>
<script type="text/VBScript">

Sub vb_function(args)
call javascript_function(args+"passed to vb")
end sub

</script>
<script type="text/JavaScript">

function javascript_function(args) {
alert(args + "\npresented in js\n\nglobal: "+global);
}

</script>
<body onload="vb_function(global)">

</body>
</html>



Remember that the first script tag becomes the default language of the page.



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum