【 Document オブジェクト 】

1. 殆ど全てのインターフェイス
2. ターゲットページの URL 一覧を表示する
3. window オブジェクトからクリップボードへアクセス

  • Document オブジェクトは、通常 DHTML で使用する document オブジェクトと同じものです

  • window オブジェクトをはじめとする殆ど全てのオブジェクトにアクセスできます

  • その事実を最も顕著にあらわすのが、ページ内の全ての記述を取得する事のできる innerHTML プロ
    パテイへのアクセスです。以下にそのサンプルを示します
  • <SCRIPT language=VBScript>
     
    Dim Ie
     
    Set Ie = CreateObject("InternetExplorer.Application")
    Ie.Visible = True
    Ie.Navigate("http://hp.vector.co.jp/authors/VA003334/winofsql/document.htm")
     
    function TargetWriteLoad()
     
    	strHTML = Ie.Document.all.tags("HTML")(0).innerHTML
    	Ie.Quit
    	document.write strHTML
     
    end function
     
    </SCRIPT>
     
    <INPUT type=button value="ターゲットの表示" onClick='Call TargetWriteLoad()'>
    


    漢字コードの変換
  • オリジナルページでは、漢字コードは EUC-JP の為ソースを notepad で
    表示すると文字化けしますが、ドキュメントオブジェクトを介して表示すると
    正しく表示されます


  • all コレクションを使用して href 属性を全て表示します

  • <SCRIPT language=VBScript>
     
    Dim Ie
     
    Set Ie = CreateObject("InternetExplorer.Application")
    Ie.Visible = True
    Ie.Navigate("http://hp.vector.co.jp/authors/VA003334/")
     
    function TargetLinkLoad()
     
    	Dim AllList
     
    	Set AllList = Ie.Document.all
    	For Each AllObject in  AllList
    		on error resume next
    		document.write AllObject.href & "<br>"
    		on error goto 0
    	Next
     
    	Ie.Quit
     
    end function
     
    </SCRIPT>
     
    <INPUT type=button value="ターゲットの表示" onClick='Call TargetLinkLoad()'>
    
  • anchors コレクションでは全て表示されないので注意して下さい。document オブジェクト内では通常
    all コレクションを使用します。これがもっとも確実なオブジェクトへの参照を得る方法です


  • 目的がクリップボードなので、ページをロードする必要はありません。about:blank を使用します

  • window オブジェクトは、Document オブジェクトの parentWindow プロパティであり、window オブジェクト
    clipboardData オブジェクトが存在します

  • <SCRIPT language=VBScript>
     
    Dim Ie
     
    Set Ie = CreateObject("InternetExplorer.Application")
    Ie.Visible = True
    Ie.Navigate("about:blank")
     
    function CopyData()
     
    	Dim window,clipboardData,strClip
     
    	Set window = Ie.Document.parentWindow
    	Set clipboardData = window.clipboardData
     
    	alert( window.closed )
     
    	strClip = window.location & vbCrLf
    	strClip = strClip & "クリップボードヘコピーしました" & vbCrLf
    	strClip = strClip & "取り出すのは getData(""TEXT"")です" & vbCrLf
     
    	Call clipboardData.setData( "TEXT", strClip )
     
    	Ie.Quit
     
    	alert( window.closed )
     
    end function
     
    </SCRIPT>
     
    <INPUT type=button value="クリップボートへコピー" onClick='Call CopyData()'>
    
  • 最初の alert は False で、Ie.Quit 後の alert は True です

  • IE 内の VBScript ならば、自分自身の window オブジェクトを使用すれば良いのですが、他のVBScript
    でクリップボードにアクセスしたい場合には使えるかもしれません