更新时间:2023-10-28 15:35:04
根元素始终存在。您可以将< script>
附加到< html>
元素:
The root element always exist. You can just append the <script>
to the <html>
element:
var s = document.createElement('script');
s.textContent = 'console.log("Test");';
document.documentElement.appendChild(s);
s.parentNode.removeChild(s); // Just to clean-up.