13
私はHTML文書の先頭にあるスクリプトを実行しており、Internet Explorer以外のすべてのブラウザで動作します。 Opera、Safari、Chrome、Firefox、Internet Explorerでテストされています。次のようにdocument.head.appendChildまたはdocument.createElementがIEで動作しません
私のコードは次のとおりです。
<html>
<head>
<script type = "text/javascript">
var date = new Date();
var month = date.getMonth() + 1;
if (month >= 3 && month <= 5)
{
var NewScript = document.createElement("script");
NewScript.type = "text/javascript";
NewScript.src = "source1.js";
var NewStyles = document.createElement("link");
NewStyles.rel = "stylesheet";
NewStyles.type = "text/css";
NewStyles.href = "css1.css";
document.head.appendChild(NewScript);
document.head.appendChild(NewStyles);
}
else
{
var NewScript = document.createElement("script");
NewScript.type = "text/javascript";
NewScript.src = "source2.js";
var NewStyles = document.createElement("link");
NewStyles.rel = "stylesheet";
NewStyles.type = "text/css";
NewStyles.href = "css2.css";
document.head.appendChild(NewScript);
document.head.appendChild(NewStyles);
}
</script>
</head>
<body>
<!-- MY CONTENT GOES HERE -->
</body>
</html>
私はそれはIEで動作していないのdocument.createElementやdocument.head.appendChildだかはわかりません。以前に述べたように、私はそれをテストした他のすべてのブラウザで動作します。この問題は、自分自身で解決策を見つけ続けるので大いに感謝します。ありがとう!
ああをお試しください!あなたは命の恩人です!私はほとんどすべてを試みた。私は今年の季節に基づいて異なるテーマを作成しています。そして、私の次のプロジェクトは休日のテーマです。再度、感謝します! –