'首先form1加入WebBrowser控件,并打开一个页面Private Sub Form_Load()
WebBrowser1.Navigate "c:\index.htm"
End Sub
' 这里为是获取WebBrowser1里面的操作
Public Sub WebBrowser1_StatusTextChange(ByVal Text As String)
  st1 = Text
  Label1.Caption = st1
  End If
End Sub
'下面为index.htm里面的代码(直接贴到记事本另存为index.htm)
<A href=# onclick="javascript: aaa('hello !!!!!!!!!!');">传递到from</A> <b>
 <SCRIPT LANGUAGE=javascript>
 function aaa(sss)
{
window.status=(sss)
}
 </SCRIPT>现在问题来了:
hello!!!!!!可以传递到label1,但是无法调用
比如msgbox st1
如何将hello!!!!!变为一个可以调用的变量啊

解决方案 »

  1.   

    同时寻求能把WebBrowser里面的htm连接的参数
    变成vb里面可以调用的变量的办法比如: http://www.xxxx.xxx/xxx.asp?username=gogogo希望能把gogogo给传到vb里面
      

  2.   

    第一个没看明白,你想作什么?第二个:
    Private Declare Function ShellExecute Lib "shell32.dll" Alias "ShellExecuteA" (ByVal hwnd As Long, ByVal lpOperation As String, ByVal lpFile As String, ByVal lpParameters As String, ByVal lpDirectory As String, ByVal nShowCmd As Long) As LongPrivate Sub Command1_Click()
        ShellExecute 0&, vbNullString, "http://www.xxxx.xxx/xxx.asp?username=" & gogogoNameValue, vbNullString, vbNullString, vbNormalFocus
    End Sub
      

  3.   

    可能是我说的不够清楚吧hello!!!!是鼠标点击网页后的传给vb的值在label里面可以看到,可是无法使用
      

  4.   

    老大,既然能够赋值给LABEL,那干嘛不直接把Label1.Caption当stl来用,还有,真的看不出stl是什么东西……没变量声明的习惯以后会吃亏d……
    还有干嘛用StatusTextChange?这个是提示栏内容改变后就发生的,8好用d
    你的问题都可以用下面的东西来解决Private Sub WebBrowser1_BeforeNavigate2(ByVal pDisp As Object, URL As Variant, Flags As Variant, TargetFrameName As Variant, PostData As Variant, Headers As Variant, Cancel As Boolean)
    Debug.Print URL
    End Sub比如你在网页里面的链接http://www.xxxx.xxx/xxx.asp#1
    http://www.xxxx.xxx/xxx.asp#2
    http://www.xxxx.xxx/xxx.asp?username=gogogo自己分析URL即可。
    最后,记得结贴给分
      

  5.   

    还有,如不想让页面转移,用#username=gogogo取代?username=gogogo
      

  6.   

    ByVal pDisp As Object, URL As Variant, Flags As Variant, TargetFrameName As Variant, PostData As Variant, Headers As Variant, Cancel As Boolean
    能说一下这些代表着什么吗??分我给你了
      

  7.   

    Private Sub object_BeforeNavigate2(ByVal pDisp As Object, ByVal URL As String, 
    ByVal Flags As Long, ByVal TargetFrameName As String, PostData As Variant, 
    ByVal Headers As String, Cancel As Boolean)Value Description 
    object Required. An object expression that evaluates to an object in the Applies To list. 
    pDisp An object that evaluates to the top-level or frame WebBrowser object corresponding to the navigation.  
    URL A string expression that evaluates to the URL to which the browser is navigating.  
    Flags Reserved for future use.  
    TargetFrameName A string expression that evaluates to the name of the frame in which the resource will be displayed, or NULL if no named frame is targeted for the resource. 
    PostData Data to send to the server if the HTTP POST transaction is being used.  
    Headers A value that specifies the additional HTTP headers to send to the server (HTTP URLs only). The headers can specify things like the action required of the server, the type of data being passed to the server, or a status code. 
    Cancel A Boolean value that the container can set to TRUE to cancel the navigation operation, or to FALSE to allow it to proceed.  pDisp 是控件用的,URL 就是网址了,Flags 预留扩展用的,TargetFrameName 框架名(也就是网址的应用页面框架),PostData 是提交的数据(比如用表单提交的数据),Headers 是附加的标识(不懂的去查HTML4.0的书),Cancel 的意思是是否取消该链接(意思就是不让该网址转向生效,很好用的功能,比如禁止别人上SINA.COM就先检查URL里面是否有“SINA”这几个字,有的话就TRUE ,那么你的浏览器就不会转向到SINA.COM了)