This is great!!
However, I am not great regarding JS...
Tried but failed.
When I use it in HTML it works but when trying unobtrusive JS I dont know how to think about it. I tried to put this at the end of the script in a initializing function.
function hideAll() is onload and function show('Lay1') and function stopTime() is not onload. So does that make a difference regarding where to put them in the script?
html
<a href="#" onclick="hideAll(); show('Layer1'); stopTime()">
<a href="#" onclick="hideAll(); show('Layer2'); stopTime()">
<a href="#" onclick="hideAll(); show('Layer3'); stopTime()">
<a href="#" onclick="hideAll(); show('Layer4'); stopTime()">
JS
var timerID = null;
var timerOn = false;
var timecount = 1;
function show(layerName) {
document.getElementById(layerName).style.display ='block';
}
function hide(layerName) {
document.getElementById(layerName).style.display ='none';
}
function hideAll() {
hide('LAYER1');
hide('LAYER2');
hide('LAYER3');
hide('LAYER4');
}
function startTime() {
if (timerOn == false) {
timerID=setTimeout( "hideAll()" , timecount);
timerOn = true;
}
}
function stopTime() {
if (timerOn) {
clearTimeout(timerID);
timerID = null;
timerOn = false;
}
}
I want to call the functions from the JSfile with addeeventlisteners. Doing that I also need to get an id for every link, that also will change the code in the JSfile.
How get the functions call to the JSfile and how make the link idīs to work in the JS file?
Bookmarks