我的网站出现了错误" Uncaught TypeError:无法读取属性' style' of null"。
<li id="nav-AI" role="presentation" style="display: none"><a href="/AIMakerSpace">AI Maker Space</a>
<ul>
<li><a href="/AIMakerSpace">關於AIMS</a></li>
<li><a href="/support-TW">技術支持</a></li>
</ul>
</li>
<div class="dropdown">
<img id="speakchange" src="images/speakchange.png" alt="" onclick="menu.style.display='block';">
<div id="menu">
<ul class="nostyle" role="menu">
<li><input id="changeCN" type="button" value="简体" onclick="changeCN()"></li>
<li><input id="changeTW" type="button" value="繁体" onclick="changeTW()"></li>
<li><input id="changeEN" type="button" value="英文" onclick="changeEN()"></li>
</ul>
</div>
</div>
我的js是:
<script type="text/javascript">
function changeCN() {
document.getElementById("changeCN");
TAPi18n.setLanguage('en');
var obd=document.getElementById("body");
obd.style.fontFamily="'Microsoft YaHei',SimSun,Verdana,simsun,sans-serif";
document.getElementById("nav-AI").style.display="none";
document.getElementById("logo").src="images/Geometric.png";
}
function changeEN() {
document.getElementById("changeEN");
TAPi18n.setLanguage('cn');
var obd=document.getElementById("body");
obd.style.fontFamily="'Helvetica Neue', Helvetica, Arial, sans-serif";
document.getElementById("nav-AI").style.display="none";
document.getElementById("logo").src="images/Geometric-TW.png";
}
function changeTW() {
document.getElementById("changeTW");
TAPi18n.setLanguage('tw');
var obd=document.getElementById("body");
obd.style.fontFamily="'Microsoft JhengHei',SimSun,Verdana,sans-serif";
document.getElementById("nav-AI").style.display="inline";
document.getElementById("logo").src="images/Geometric-TW.png";
}
window.onload=function() {
changeCN();
changeEN();
changeTW();
}
</script>
我使用&#34; window.onload&#34;但它没有用,我不知道如何解决它。