HOWTO: Pass Parameters from HTML to ActiveX DocumentsID: Q188018
|
When you are launching a Visual Basic 5.0 UserDocument under Internet
Explorer, you may want to pass it some information. You cannot call public
methods and properties of the UserDocument from within the HTML for two
reasons. First, as soon as the UserDocument loads, the HTML page used to
launch it is destroyed. Second, Internet Explorer does not consider
UserDocuments safe for scripting.
This article shows you a technique to pass information to the UserDocument
you are launching from within the launching HTML page.
You can pass parameters to the UserDocument you are launching as a query string using the question mark(?) in the URL. After passing the desired information using the question mark from the HTML, you can retrieve it in your UserDocument.
Location.Replace = "MyDoc.VBD?MyParametersStr"The string ParameterStr is passed using the question mark above. The question mark (?) is typically used to pass query string information. In addition to using Location.Replace, you can also navigate using Location.HREF, Window.Navigate, or a simple <A> tag.
<SCRIPT LANGUAGE="VBScript">
Sub Window_OnLoad()
' For relative URLs, ? should be explicitly escaped to %3F
' for Internet Explorer 4
location.href = "userdocument1.vbd%3FMyParamString"
' For absolute file urls, the ? is automatically escaped to %3F
location.href = "file://c:\Tests\userdocument1.vbd?MyParamString"
End Sub
</SCRIPT>
Private Sub UserDocument_Show()
Dim Param
Dim P As Integer
P = InStr(Parent.LocationURL, "%3F")
If P > 0 Then
Param = Mid$(Parent.LocationURL, P + 3)
End If
MsgBox "Got : " & Param
End Sub
For additional information, please see the following articles in the Microsoft Knowledge Base:
Q168431 PRB: Launching VB5 ActiveX Documents from Internet Explorer
Q181674 BUG: File Protocol URLs Do Not Work Correctly with # Fragments
Additional query words: kbIE401sp1 kbIE400 kbIE401
Keywords : kbIE400 kbIE401 kbVBp500 kbVBp600 kbIE302 kbIE401sp1 kbIE500
Version : WINDOWS:3.02,4.0,4.01,4.01sp1,5.0
Platform : WINDOWS
Issue type : kbhowto
Last Reviewed: May 3, 1999