abc
def
新しいAttrオブジェクトを生成して返します。
- 構文
- attribute = Document.createAttribute( name )
- 引数
- name
- 属性の名前
- 戻り値
関連するメソッド・プロパティ
プログラム実行例
要素に属性を追加する
DIM IE = CREATEOLEOBJ("InternetExplorer.Application")
IE.Visible = TRUE
IE.Navigate("http://www.example.com")
BusyWait(IE)
SLEEP(3.000)
DIM Elements = IE.document.getElementsByTagName("h1")
DIM Element = Elements.Item(0)
DIM AttrNode = IE.document.createAttribute("style")
AttrNode.value = "color:red;"
Element.setAttributeNode(AttrNode)
//////////////////////////////////////////////////
// 【引数】
// IE : IEオブジェクト
// 【戻値】
//
//////////////////////////////////////////////////
PROCEDURE BusyWait(Var IE)
SLEEP(0.500)
DIM t = GETTIME()
TRY
REPEAT
DIM tm = GETTIME() - t
FUKIDASI("BusyWait:" + tm)
SLEEP(0.010)
IF tm >= 60 THEN BREAK
UNTIL !IE.Busy AND IE.readyState = 4
EXCEPT
IE = getIEObj(-1)
PRINT IE.document.URL + " のIEオブジェクトを取得しました。"
BusyWait(IE)
ENDTRY
FUKIDASI()
FEND
//////////////////////////////////////////////////
// 【引数】
// 文字列 or 数値 : 取得したいIEオブジェクトのタイトル・URLもしくは数値を指定
// 完全一致フラグ : (TRUE : 文字列が完全一致したものを取得、FALSE : 文字列の一部を含むものを取得)
// 【戻値】
// Internet Explorerオブジェクト
//////////////////////////////////////////////////
FUNCTION getIEObj(str, flg = FALSE)
DIM Shell = CREATEOLEOBJ("Shell.Application")
SELECT CHKNUM(str)
CASE TRUE
DIM cnt = 0
SELECT TRUE
CASE str > 0
FOR n = 0 TO Shell.Windows.Count - 1
TRY
IFB Shell.Windows.Item(n).Name = "Internet Explorer" THEN
cnt = cnt + 1
IFB str = cnt THEN
RESULT = Shell.Windows.Item(n)
EXIT
ENDIF
ENDIF
EXCEPT
ENDTRY
NEXT
CASE str = 5
SELEND
RESULT = ERR_VALUE
FEND
- 結果
<div> <h1 style="color: red;">Example Domain</h1> <p>This domain is for use in illustrative examples in documents. You may use this domain in literature without prior coordination or asking for permission.</p> <p><a href="https://www.iana.org/domains/example">More information...</a></p> </div>