Permalink
Switch branches/tags
Nothing to show
Find file
Fetching contributors…
Cannot retrieve contributors at this time
39 lines (30 sloc) 703 Bytes
<!DOCTYPE html>
<html>
<head>
<title>script内の関数を実行</title>
<meta charset="UTF-8">
</head>
<body>
<p id="text">〇〇〇</p>
<script>
//IEとそれ以外で分けて、DOMの構成が終了を知らせるイベントをつくる。
var userAgent = window.navigator.userAgent.toLowerCase();
if (userAgent.indexOf('msie') != -1)
{
console.log("IE");
window.attachEvent("onload",filltext());
}
else
{
console.log("IE以外");
document.addEventListener("DOMContentLoaded",filltext(),true);
}
//textを埋めるためのscript
function filltext()
{
var text = document.getElementById("text");
text.innerHTML = "Hello World";
}
</script>
</body>
</html>