tagCANDY CGI VBレスキュー(花ちゃん) の Visual Basic 2010 用 掲示板(VB.NET 掲示板)
VBレスキュー(花ちゃん) の Visual Basic 2010 用 掲示板(VB.NET 掲示板)
[ツリー表示へ]  [ワード検索]  [Home]

タイトル vb.netから、javascriptのinputタグの追加
投稿日: 2009/08/13(Thu) 14:32
投稿者ペルソナ
先日、投稿させていただきました続きで

VBからhtmlを起動する際
javascriptで作成されたinputタグを
動的にVBから作成したいのですが
方法が分からなく、こまっております。

※TEST.html
<html>
<head>
<script language="JavaScript"><!--

function openWin()
{
 var wd;
 var objForm = document.form1 ;
 var url = "http://localhost/index.asp";-@

 wd = window.open( "",
          "_new",
          "resizable=yes, scrollbars=yes, location=yes, menubar=yes"
         );

 wd.focus();
 objForm.target = "_new";
 objForm.action = url;
 objForm.method = "POST";
 objForm.submit();
}
//--></script>
</head>
<body onload="openWin()">
<form name="form1">
<input type="hidden" name="param1" value="test1">-A
<input type="hidden" name="param2" value="test2">-B
</form>
</body>

※VBソース
Private Sub AxWebBrowser1_DocumentComplete(ByVal sender As Object, ByVal e As AxSHDocVw.DWebBrowserEvents2_DocumentCompleteEvent) Handles AxWebBrowser1.DocumentComplete

        '以前のオブジェクトを解放
        If Not doc Is Nothing Then
            System.Runtime.InteropServices.Marshal.ReleaseComObject(doc)
        End If

        doc = AxWebBrowser1.Document

        Dim names As mshtml.IHTMLElementCollection

        names = doc.getElementsByTagName("input")

        Dim Ary() As String = InputParam.Split("&")

        For intCnt As Integer = 0 To UBound(Ary)
            Dim input As mshtml.HTMLInputElement = names.item(intCnt)
            input.type = "hidden"
            input.name = Ary(intCnt).Substring(0, Ary(intCnt).IndexOf("="))
            input.value = Ary(intCnt).Substring(Ary(intCnt).IndexOf("=") + 1)
            System.Runtime.InteropServices.Marshal.ReleaseComObject(input)
        Next intCnt

    End Sub

以上は、VBからhtmlの既存のinputタグに値を代入するロジックです。
VBから、TEST.htmlを読み込む際
パラメータとして、script内(@)のurlがを変更する必要がある事と
パラメータの数が可変の為、inputタグ(A・B)を動的に作成する必要が
あるのです。

以上、長くなりましたが
どなたかご教授願います。

- 関連一覧ツリー をクリックするとツリー全体を一括表示します)

古いスレッドにレスはつけられません。