[英]How to append <script> to Head or Body Using Javascript?
[英]How to append script, link, and meta tags onto head using JavaScript?
我得到如下輸出,如何使用JavaScript將整個內容附加到head標簽中?
<meta name="generator" content="Joomla! - Open Source Content Management" />
<title></title>
<link rel="stylesheet" href="templates/css/template.css" />
<link rel="stylesheet" href="templates/css/templatee.css" />
<style type="text/css">
<![CDATA[
BODY {background: #00ff00;color: rgb(0,0,255);}
]]>
</style>
您可以嘗試以下方法:
document.querySelector('head').innerHTML = "insert your code here"
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.