getElementsByTagName() only shows opening tag for "nav" and "section"

Get help with using AutoHotkey (v2 or newer) and its commands and hotkeys
RomAnT
Posts: 21
Joined: 23 Sep 2021, 13:19

getElementsByTagName() only shows opening tag for "nav" and "section"

25 Sep 2021, 09:10

This only shows opening tag for HTML5 tags section and nav however works with all other HTML4 tags. Is there solution?
I am on Windows 7.

Code: Select all

HTMLObj := ComObject("HTMLfile")
HTMLObj.write(HTML)

DOMObj := HTMLFileObj.getElementsByTagName("section")  ;or "nav"

msgbox DOMObj[0].outerHTML

; returns "<section class=mysection>"
swagfag
Posts: 6222
Joined: 11 Jan 2017, 17:59

Re: getElementsByTagName() only shows opening tag for "nav" and "section"

25 Sep 2021, 14:58

check what HTMLObj.documentMode the comobj starts off with. anything short of 11 probly doesnt have .outerHTML working correctly for these elements.
if so, switch the mode by adding the meta-tag or applying the registry fix(see viewtopic.php?p=422001#p422001 for info)
RomAnT
Posts: 21
Joined: 23 Sep 2021, 13:19

Re: getElementsByTagName() only shows opening tag for "nav" and "section"

23 Oct 2021, 08:23

I really dont understand what i should do to fix this. Adding

Code: Select all

<meta http-equiv="X-UA-Compatible" content="IE=edge">
to the HTML page did not help.

Also another issue i have <noscript></noscript> comes out empty without any contents.

Code: Select all

HTML := '<!DOCTYPE html> <html> <head> <meta charset="UTF-8"> <title></title> <style> </style> <script> //mysecipt 1 </script> <noscript>no script 1</noscript> </head> <body> <script> //mysecipt 2 </script> <noscript>no script 2</noscript> <div>Hello World!</div></body> </html>'

htmlObj := ComObject("HTMLfile")
htmlObj.write(HTML)

domElement := htmlObj.getElementsByTagName("script")
msgbox domElement[0].outerHTML  ; returns "<SCRIPT> //mysecipt 1 </SCRIPT>"

domElement := htmlObj.getElementsByTagName("noscript")
msgbox domElement[0].outerHTML  ; returns "<NOSCRIPT></NOSCRIPT>"
swagfag
Posts: 6222
Joined: 11 Jan 2017, 17:59

Re: getElementsByTagName() only shows opening tag for "nav" and "section"

28 Oct 2021, 14:43

RomAnT wrote:
23 Oct 2021, 08:23
Adding <meta http-equiv="X-UA-Compatible" content="IE=edge"> to the HTML page did not help.
added where? theres no such tag anywhere in what u posted. no tag = no work(unless u do the registry fix)

Return to “Ask for Help (v2)”

Who is online

Users browsing this forum: kunkel321, Noitalommi_2, songdg, william_ahk and 54 guests