I have an html page (http://www.autoelettric.com/info/SafeConversionToLed.html) that when I click on button the status bar on top will change. The site would be designed for easy navigation through the buttons, but if an user uses the scroll, the status bar is not updated. So I would like to know if can I do an event that updates the status bar on the change of url (httt.url.com # step1, httt.url.com # step2, httt.url.com # step3).
For example, my code now:
Script:
<script type = "text/javascript">
function status0()
{
document.getElementById("imgStausBar").src ="status0.png";
}
function status1()
{
document.getElementById("imgStausBar").src ="status1.png";
}
function status2()
{
document.getElementById("imgStausBar").src ="status2.png";
}
function status3()
{
document.getElementById("imgStausBar").src ="status3.png";
}
</script>
Html
<a href="#FlasherUnit" onclick="status1()"><div class="btn-5" width="50px">↓ START</div></a>
<a href="#ExactPower" onclick="status3()"><div class="btn-5" width="50px">→ YES</div></a>
<a href="#FlasherUnit" onclick="status1()"><div class="btn-5-previous" width="50px">↩ PREVIOUS</div></a>
<a href="#SafeConversion" onclick="status0()"><div class="btn-5-top" width="10px">↑</div></a>
What I would do:
if current url is #SafeConversion do status0()
if current url is #FlasherUnit do status1()
if current url is #ExactPower do status2()
etc...
EDIT:
I added this, but it doesn't work.
if ("onhashchange" in window) { // event supported?
window.onhashchange = function () {
hashChanged(window.location.hash);
}
}
else {
var locationHash = window.location.hash;
window.setInterval(function () {
if(locationHash == "#SafeConversion") {
status0();
} else if(locationHash == "#FlasherUnit") {
status1();
} else if(locationHash == "#ExactPower") {
status2();
} else if(locationHash == "#ExactPower") {
status2();
} else if(locationHash == "#YourSolution") {
status3();
} else if(locationHash == "#YourSolution2") {
status3();
} else if(locationHash == "#YourSolution2/1") {
status3();
} else if(locationHash == "#YourSolution3") {
status3();
} else if(locationHash == "#YourSolution3/1") {
status3();
} else if(locationHash == "#YourSolution4") {
status3();
} else if(locationHash == "#Contact") {
status0();
}
}, 100);
}