WebBrowser - VBScript Issues

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Trevor Fairchild

    #1

    WebBrowser - VBScript Issues

    I'm trying to have VB6 write an html file during run-time, with some
    VBScript functionality. The intent is to display images based on the
    current record within the program - using a WebBrowser - plus some
    buttons to dynamically resize the image.

    I have gotten almost everything to work - I put in a function to
    simply disable the right-click option of the browser, but none of the
    other functions work.

    If I copy the source data out of the WebBrowser control and open it in
    IE6 - everything works as it is supposed to, but not within the
    WebBrowser as an object in VB6...

    Obviously the control supports vbscript because the right-click works.

    Any ideas on what I am doing wrong:

    <html>
    <head>
    <title>C4P Image</title>
    <SCRIPT type ="text/vbscript">
    <!--
    Option Explicit
    dim myWidth, myHeight

    Sub Startup()
    myWidth = Document.forms( "myForm").All.i tem("imgTarget" ).width
    myHeight = Document.forms( "myForm").All.i tem("imgTarget" ).height
    End Sub

    Sub cmdShrink_OnCli ck()
    Document.forms( "myForm").All.i tem("imgTarget" ).width =
    Document.forms( "myForm").All.i tem("imgTarget" ).width *0.5
    Document.forms( "myForm").All.i tem("imgTarget" ).height =
    Document.forms( "myForm").All.i tem("imgTarget" ).height * 0.5
    End Sub

    Sub cmdGrow_OnClick ()
    Document.forms( "myForm").All.i tem("imgTarget" ).width =
    Document.forms( "myForm").All.i tem("imgTarget" ).width *2
    Document.forms( "myForm").All.i tem("imgTarget" ).height =
    Document.forms( "myForm").All.i tem("imgTarget" ).height * 2
    End Sub

    Sub cmdReset_OnClic k()
    Document.forms( "myForm").All.i tem("imgTarget" ).width = myWidth
    Document.forms( "myForm").All.i tem("imgTarget" ).height =
    myHeight
    End Sub

    Sub CatchMouseDown( )
    if Window.event.bu tton = 2 Then
    Alert("right-click off")
    End If
    End sub
    -->
    </SCRIPT>
    </head>
    <body onMouseDown="Ca tchMouseDown()" onload = "Startup" >
    <form name = "myForm" >
    <table CELLSPACING="0" CELLPADDING="0" VALIGN="CENTER"
    WIDTH="100%" HEIGHT="100%" BORDER="0">
    <tr><td align="center">
    <table id="container" CELLSPACING="0" CELLPADDING="0"
    VALIGN = "CENTER" WIDTH="90%" HEIGHT="90%" BORDER="0">
    <tr><td>
    <p align="center"> <img border="0" src="picture.jp g"
    loop = "infinite" width="120" height="43" name = "imgTarget" ></p>
    </td></td>
    </table>

    <p align = "center">
    <input type = "button" value = "Smaller" name =
    "cmdShrink" />
    <input type = "button" value = "Larger" name = "cmdGrow"
    />
    <input type = "button" value = "Reset" name = "cmdReset"
    />
    </p>
    </td></tr>
    </table>
    </form>
    </body>
    </html>
Working...