#1
  1. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Feb 2013
    Location
    California, USA
    Posts
    78
    Rep Power
    5

    New to VBScript - How to do event-driven script


    I've just started studying VBScript. I can't get the example to work.
    Internet Explorer is opened and the button is created, but does not show any results when the button is clicked.

    The code is saved with ".htm" as the extension and double-clicked from explorer on a Windows 7
    laptop with Internet Explorer 11.

    Thanks for helping me get a start on this.

    Code:
    <HTML>
    <HEAD>
    <TITLE>Simple VBScript Example</TITLE>
    <script language="VBScript">
        Sub ButtonClicked
            window.alert ("You clicked on the button!")
        End Sub
    </script>
    </HEAD>
    <BODY>
        <BUTTON NAME="Button1" TYPE="BUTTON" ONCLICK="ButtonClicked">
        Click Me!
        </BUTTON>
    </BODY>
    </HTML>
  2. #2
  3. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Feb 2013
    Location
    California, USA
    Posts
    78
    Rep Power
    5
    I tried the same code on another PC with Windows 7 and got the same results: nothing happened when
    I clicked the button. Then I tried it on a PC with Windows XP. Internet Explorer prompted to allow running the
    script, with a warning. I allowed the script and the code worked as expected when I clicked the button.

    Perhaps I'm learning that Windows 7 and web browsers don't take kindly to this type of script.

IMN logo majestic logo threadwatch logo seochat tools logo