←back to thread

Element: setHTML() method

(developer.mozilla.org)
167 points todsacerdoti | 3 comments | | HN request time: 0.465s | source
1. sergeykish ◴[] No.45677170[source]
So `.setHTML("<script>...</script>")` does not set HTML?
replies(2): >>45677372 #>>45678816 #
2. xp84 ◴[] No.45677372[source]
Sounds reasonable enough to me. 99.99% of the times you’re in an actual script, if you mean to execute code, you’d just execute it yourself, rather than making a script tag full of code and sticking that tag into a random DOM element. That’s why the default wouldn’t honor the script tag and there’d be an “unsafe” method explicitly named as such to hint you that you’re doing something weird.
3. WA ◴[] No.45678816[source]
Neither does

    .innerHTML = "<script>...</script>"