VBScript 无法设置 HTML 名称属性
VBScript can't set HTML name attribute
我正在尝试使用 VBScript 作为语言在 HTA 应用程序中生成 HTML 页面。
我似乎无法设置元素名称属性。除了设置名称的代码外,此代码均有效。我最后输出了frmMenu.InnerHTML。
set selectApp = document.createElement("select")
selectApp.ID = "selApplication"
selectApp.name = "selApplication"
frmMenu.appendChild(selectApp)
Set selectApp.onchange = GetRef("Application_Change_Event")
我用过 selectApp.Name = "selApplication" 也没有用。
这是整个 Sub()
GetRef("CycleMappingPage")
CycleMappingPage()
Sub CycleMappingPage()
Set label1 = document.createElement("label")
label1.innerHTML = "Application: "
frmMenu.appendChild(label1)
set selectApp = document.createElement("select")
selectApp.ID = "selApplication"
selectApp.name = "selApplication"
frmMenu.appendChild(selectApp)
Set selectApp.onchange = GetRef("Application_Change_Event")
Set br1= document.createElement("br")
frmMenu.appendChild(br1)
Set br2 = document.createElement("br")
frmMenu.appendChild(br2)
Set label2 = document.createElement("label")
label2.innerHTML = "Cycle: "
frmMenu.appendChild(label2)
Set selectCycle = document.createElement("select")
selectCycle.setAttribute "name", "selCycle"
frmMenu.appendChild(selectCycle)
Set br3= document.createElement("br")
frmMenu.appendChild(br3)
Set br4 = document.createElement("br")
frmMenu.appendChild(br4)
Set inputButtonGenMap = document.createElement("input")
inputButtonGenMap.setAttribute "type", "button"
inputButtonGenMap.setAttribute "name", "btnRun"
inputButtonGenMap.setAttribute "value", "Generate Map"
frmMenu.appendChild(inputButtonGenMap)
Set inputButtonGenMap.onclick = GetRef("GenerateMap")
Set br5= document.createElement("br")
frmMenu.appendChild(br5)
Set br6 = document.createElement("br")
frmMenu.appendChild(br6)
Set inputButtonMainMenu = document.createElement("input")
inputButtonMainMenu.setAttribute "type", "button"
inputButtonMainMenu.setAttribute "name", "btnMainMenu"
inputButtonMainMenu.setAttribute "value", "Main Menu"
frmMenu.appendChild(inputButtonMainMenu)
Set inputButtonMainMenu.onclick = GetRef("LoadMainMenuPage")
msgbox frmMenu.innerHTML
End Sub
这是旧版 IE(IE8 之前)的行为。您有两种选择来解决它。
1) 在createElement
调用中指定名称:
Set sel = document.createElement("<select name='hello'/>")
2) 使用 X-UA-Compatible header 将 HTA 的兼容模式至少更改为 IE 8(参见 "X-UA-Compatible" content="IE=9; IE=8; IE=7; IE=EDGE")
此行为记录在 name
属性:
In Internet Explorer 8 and later versions, you can set the name attribute at run time on elements that are dynamically created with the createElement method. To create an element with a name attribute in earlier versions of Windows Internet Explorer, include the attribute and its value when you use the createElement method.
我正在尝试使用 VBScript 作为语言在 HTA 应用程序中生成 HTML 页面。
我似乎无法设置元素名称属性。除了设置名称的代码外,此代码均有效。我最后输出了frmMenu.InnerHTML。
set selectApp = document.createElement("select")
selectApp.ID = "selApplication"
selectApp.name = "selApplication"
frmMenu.appendChild(selectApp)
Set selectApp.onchange = GetRef("Application_Change_Event")
我用过 selectApp.Name = "selApplication" 也没有用。
这是整个 Sub()
GetRef("CycleMappingPage")
CycleMappingPage()
Sub CycleMappingPage()
Set label1 = document.createElement("label")
label1.innerHTML = "Application: "
frmMenu.appendChild(label1)
set selectApp = document.createElement("select")
selectApp.ID = "selApplication"
selectApp.name = "selApplication"
frmMenu.appendChild(selectApp)
Set selectApp.onchange = GetRef("Application_Change_Event")
Set br1= document.createElement("br")
frmMenu.appendChild(br1)
Set br2 = document.createElement("br")
frmMenu.appendChild(br2)
Set label2 = document.createElement("label")
label2.innerHTML = "Cycle: "
frmMenu.appendChild(label2)
Set selectCycle = document.createElement("select")
selectCycle.setAttribute "name", "selCycle"
frmMenu.appendChild(selectCycle)
Set br3= document.createElement("br")
frmMenu.appendChild(br3)
Set br4 = document.createElement("br")
frmMenu.appendChild(br4)
Set inputButtonGenMap = document.createElement("input")
inputButtonGenMap.setAttribute "type", "button"
inputButtonGenMap.setAttribute "name", "btnRun"
inputButtonGenMap.setAttribute "value", "Generate Map"
frmMenu.appendChild(inputButtonGenMap)
Set inputButtonGenMap.onclick = GetRef("GenerateMap")
Set br5= document.createElement("br")
frmMenu.appendChild(br5)
Set br6 = document.createElement("br")
frmMenu.appendChild(br6)
Set inputButtonMainMenu = document.createElement("input")
inputButtonMainMenu.setAttribute "type", "button"
inputButtonMainMenu.setAttribute "name", "btnMainMenu"
inputButtonMainMenu.setAttribute "value", "Main Menu"
frmMenu.appendChild(inputButtonMainMenu)
Set inputButtonMainMenu.onclick = GetRef("LoadMainMenuPage")
msgbox frmMenu.innerHTML
End Sub
这是旧版 IE(IE8 之前)的行为。您有两种选择来解决它。
1) 在createElement
调用中指定名称:
Set sel = document.createElement("<select name='hello'/>")
2) 使用 X-UA-Compatible header 将 HTA 的兼容模式至少更改为 IE 8(参见 "X-UA-Compatible" content="IE=9; IE=8; IE=7; IE=EDGE")
此行为记录在 name
属性:
In Internet Explorer 8 and later versions, you can set the name attribute at run time on elements that are dynamically created with the createElement method. To create an element with a name attribute in earlier versions of Windows Internet Explorer, include the attribute and its value when you use the createElement method.