Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 2 of 2
  1. #1
    New Coder
    Join Date
    Jan 2004
    Posts
    17
    Thanks
    0
    Thanked 0 Times in 0 Posts

    VBScript&JScript

    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!

  • #2
    Regular Coder
    Join Date
    Aug 2002
    Location
    São Paulo, Brazil
    Posts
    367
    Thanks
    0
    Thanked 0 Times in 0 Posts
    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:
    Code:
    <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.
    /Daniel


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •