2

I'm trying to access a form by its name from the content scripts

document.querySelector("form[name=myForm]") //works fine
document.myForm //returns undefined

What is the reason I can't get a form by its name from an extension?

document.myForm //in the browser console, works as expected
Heretic Monkey
  • 11,687
  • 7
  • 53
  • 122
Slev7n
  • 343
  • 3
  • 14
  • I'm assuming you are in fact using this code within an extension and have updated the tags accordingly. Rollback the changes if not. – Heretic Monkey Jun 29 '23 at 16:22
  • 2
    It's a bug in the browser. It doesn't propagate html_document->DocumentNamedItems into the isolated world of content scripts. The workaround is to use the deprecated document.all.myForm – wOxxOm Jun 29 '23 at 18:58
  • @wOxxOm got it! thank you – Slev7n Jun 30 '23 at 09:12

0 Answers0