コード javascript script.js を含むファイル
function style(id){
document.getElementById(id).style.backgroundColor="orange";
}
var setlist = "sets.txt";
function loadXMLDoc(open){
var xmlhttp;
if (window.XMLHttpRequest){// code for IE7+, Firefox, Chrome, Opera, Safari
xmlhttp=new XMLHttpRequest();
}else{// code for IE6, IE5
xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
}
xmlhttp.onreadystatechange=function(){
if (xmlhttp.readyState==4 && xmlhttp.status==200){
document.getElementById("p1").innerHTML=xmlhttp.responseText;
}
}
xmlhttp.open("GET",open,true);
xmlhttp.send();
}
ページ内のコードで、動作しません。
<html>
<head>
<script type="text/javascript" src="script.js">
if ((onclick="loadXMLDoc(setlist)" == true)){
style("s");
}
</script>
</head>
<body>...
<dl>
<dt class="pro"><a onclick="loadXMLDoc(setlist)" id="s">Sets</a></dt>
</dl>
</body>
</html>
条件が本物の場合、id ='s' はオレンジ色で「セット」というテキストをマークしますが、それを機能させるのは好きではありません。