Results 1 to 4 of 4

Thread: How can you execute javascript in a webbrowser?

  1. #1

    Thread Starter
    Frenzied Member
    Join Date
    Jul 2003
    Posts
    1,269

    How can you execute javascript in a webbrowser?

    Anyone know?

  2. #2
    Lively Member
    Join Date
    Oct 2004
    Posts
    91

    Re: How can you execute javascript in a webbrowser?

    Using vb? Well I don't think that you could make it do that without writing a *.html file. You could shell open notepad and save a *.html file and open that but besides that I dont know how.

  3. #3
    Fanatic Member TheVader's Avatar
    Join Date
    Oct 2002
    Location
    Rotterdam, the Netherlands
    Posts
    871

    Re: How can you execute javascript in a webbrowser?

    Yes, you can, but how exactly do you mean it? Do you have a page loaded in the Web Browser control with JavaScript functions within it? Something like:
    Code:
    <head>
    <script type="text/javascript">
    function helloWorld() {
    alert("TheVader kicks ass! :P");
    }
    <script>
    </head>
    In that case, you can use the execScript method of the Document Object Model to execute the script. Like this:
    VB Code:
    1. WebBrowser1.Document.parentWindow.execScript "helloWorld()", "JScript"
    Author for Visual Basic Web Magazine

    My articles on the Web Browser Control:
    Using the Web Browser Control & Using the DHTML Document Object Model

    The examples referenced in the articles can be found here:

  4. #4
    Android OpenGL ES Guru Jacob Roman's Avatar
    Join Date
    Aug 2004
    Location
    Miami Beach, FL
    Posts
    5,285

    Re: How can you execute javascript in a webbrowser?

    Actually it's quite possible, but you must know every single command in javascript in order to execute it in VB. I doubt you may get an answer here in this section of VBForums since the majority of the people here are noobies. I'm planning on making a 3D web browser using OpenGL. So this may come in handy.

    There might be an external program that does it for you. Like WSH (Windows Scripting Host) does for VBScript. I'm not sure if that does javascript as well though.

Posting Permissions

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



Click Here to Expand Forum to Full Width