admin管理员组文章数量:1024624
Anyone know why this isn't working in Firefox?
<script type="text/javascript">
function goHo() {
hu.innerHTML="????";
}
</script>
<div class="contentPane" id="Calculator" style="display: block;">
<h2>Savings Calculator</h2><a href="Home" class="backArrow"></a>
<h3>How much do you spend on heating and hot water a year?</h3>
<div id="SpendOptions">
<ul class="optionList">
<a href="#" onMouseOut="goHo()" onMouseOver="hu.innerHTML='£60-180'"><li id="CostOption1">£600 - £900</li></a>
<a href="#" onMouseOut="goHo()" onMouseOver="hu.innerHTML='£90-240'"><li id="CostOption2">£900 - £1200</li></a>
<a href="#" onMouseOut="goHo()" onMouseOver="hu.innerHTML='£120-300'"><li id="CostOption3">£1200 - £1500</li></a>
<a href="#" onMouseOut="goHo()" onMouseOver="hu.innerHTML='£150-360'"><li id="CostOption4">£1500 - £1800</li></a>
<a href="#" onMouseOut="goHo()" onMouseOver="hu.innerHTML='£360'"><li id="CostOption5">£1800+</li></a>
</ul>
</div>
<div id="SavingsBox" style="display: block;">
<h4>This year you could save:</h4>
<h1 id="hu"></h1>
</div>
Anyone know why this isn't working in Firefox?
<script type="text/javascript">
function goHo() {
hu.innerHTML="????";
}
</script>
<div class="contentPane" id="Calculator" style="display: block;">
<h2>Savings Calculator</h2><a href="Home" class="backArrow"></a>
<h3>How much do you spend on heating and hot water a year?</h3>
<div id="SpendOptions">
<ul class="optionList">
<a href="#" onMouseOut="goHo()" onMouseOver="hu.innerHTML='£60-180'"><li id="CostOption1">£600 - £900</li></a>
<a href="#" onMouseOut="goHo()" onMouseOver="hu.innerHTML='£90-240'"><li id="CostOption2">£900 - £1200</li></a>
<a href="#" onMouseOut="goHo()" onMouseOver="hu.innerHTML='£120-300'"><li id="CostOption3">£1200 - £1500</li></a>
<a href="#" onMouseOut="goHo()" onMouseOver="hu.innerHTML='£150-360'"><li id="CostOption4">£1500 - £1800</li></a>
<a href="#" onMouseOut="goHo()" onMouseOver="hu.innerHTML='£360'"><li id="CostOption5">£1800+</li></a>
</ul>
</div>
<div id="SavingsBox" style="display: block;">
<h4>This year you could save:</h4>
<h1 id="hu"></h1>
</div>
Share
Improve this question
asked Aug 18, 2011 at 20:36
user794008user794008
111 silver badge2 bronze badges
2
- Do you think each ID creates a JavaScript variable? Or is hu defined somewhere else? If not use document.getElementById – MatTheCat Commented Aug 18, 2011 at 20:39
-
Putting all elements in
window
by their IDs is a IE perversion (which apparently has infected Safari). Replace it (everywhere) with getElementById or the appropriate jQuery call and you'll be fine. – Michael Lorton Commented Aug 18, 2011 at 20:56
4 Answers
Reset to default 5hu
should be document.getElementById("hu")
. (Just because an item has an ID, that does not mean that it will be a declared variable (id and existence as a variable have little to do with each other))
try:
function goHo() {
document.getElementById('hu').innerHTML="????";
}
You need to use document.getElementById('hu').innerHTML = "???"
You can also say:
<a href="#" onMouseOut="goHo('????')" onMouseOver="goHo('£60-180')">...
function goHo(html) {
document.getElementById('hu').innerHTML=html;
}
Demo: http://jsfiddle/8fUcG/2/
Anyone know why this isn't working in Firefox?
<script type="text/javascript">
function goHo() {
hu.innerHTML="????";
}
</script>
<div class="contentPane" id="Calculator" style="display: block;">
<h2>Savings Calculator</h2><a href="Home" class="backArrow"></a>
<h3>How much do you spend on heating and hot water a year?</h3>
<div id="SpendOptions">
<ul class="optionList">
<a href="#" onMouseOut="goHo()" onMouseOver="hu.innerHTML='£60-180'"><li id="CostOption1">£600 - £900</li></a>
<a href="#" onMouseOut="goHo()" onMouseOver="hu.innerHTML='£90-240'"><li id="CostOption2">£900 - £1200</li></a>
<a href="#" onMouseOut="goHo()" onMouseOver="hu.innerHTML='£120-300'"><li id="CostOption3">£1200 - £1500</li></a>
<a href="#" onMouseOut="goHo()" onMouseOver="hu.innerHTML='£150-360'"><li id="CostOption4">£1500 - £1800</li></a>
<a href="#" onMouseOut="goHo()" onMouseOver="hu.innerHTML='£360'"><li id="CostOption5">£1800+</li></a>
</ul>
</div>
<div id="SavingsBox" style="display: block;">
<h4>This year you could save:</h4>
<h1 id="hu"></h1>
</div>
Anyone know why this isn't working in Firefox?
<script type="text/javascript">
function goHo() {
hu.innerHTML="????";
}
</script>
<div class="contentPane" id="Calculator" style="display: block;">
<h2>Savings Calculator</h2><a href="Home" class="backArrow"></a>
<h3>How much do you spend on heating and hot water a year?</h3>
<div id="SpendOptions">
<ul class="optionList">
<a href="#" onMouseOut="goHo()" onMouseOver="hu.innerHTML='£60-180'"><li id="CostOption1">£600 - £900</li></a>
<a href="#" onMouseOut="goHo()" onMouseOver="hu.innerHTML='£90-240'"><li id="CostOption2">£900 - £1200</li></a>
<a href="#" onMouseOut="goHo()" onMouseOver="hu.innerHTML='£120-300'"><li id="CostOption3">£1200 - £1500</li></a>
<a href="#" onMouseOut="goHo()" onMouseOver="hu.innerHTML='£150-360'"><li id="CostOption4">£1500 - £1800</li></a>
<a href="#" onMouseOut="goHo()" onMouseOver="hu.innerHTML='£360'"><li id="CostOption5">£1800+</li></a>
</ul>
</div>
<div id="SavingsBox" style="display: block;">
<h4>This year you could save:</h4>
<h1 id="hu"></h1>
</div>
Share
Improve this question
asked Aug 18, 2011 at 20:36
user794008user794008
111 silver badge2 bronze badges
2
- Do you think each ID creates a JavaScript variable? Or is hu defined somewhere else? If not use document.getElementById – MatTheCat Commented Aug 18, 2011 at 20:39
-
Putting all elements in
window
by their IDs is a IE perversion (which apparently has infected Safari). Replace it (everywhere) with getElementById or the appropriate jQuery call and you'll be fine. – Michael Lorton Commented Aug 18, 2011 at 20:56
4 Answers
Reset to default 5hu
should be document.getElementById("hu")
. (Just because an item has an ID, that does not mean that it will be a declared variable (id and existence as a variable have little to do with each other))
try:
function goHo() {
document.getElementById('hu').innerHTML="????";
}
You need to use document.getElementById('hu').innerHTML = "???"
You can also say:
<a href="#" onMouseOut="goHo('????')" onMouseOver="goHo('£60-180')">...
function goHo(html) {
document.getElementById('hu').innerHTML=html;
}
Demo: http://jsfiddle/8fUcG/2/
本文标签: Javascript InnerHtml in FirefoxStack Overflow
版权声明:本文标题:Javascript InnerHtml in Firefox - Stack Overflow 内容由热心网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://it.en369.cn/questions/1745619716a2159500.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论