Onclick calls two functions at the same time?
here is my code ..
<script type="text/javascript">
function clicker(){
var thediv=document.getElementById('downloadoverlay');
if(thediv.style.display == "none"){
thediv.style.display = "";
thediv.appendChild()
return false;
}
}
function clicker1(){
var thediv1=document.getElementById('downloadbox');
if(thediv1.style.display == "none"){
thediv1.style.display = "";
thediv1.appendChild()
return false;
}
}
</script>
when the button is pressed .. the event should call two functions at the same time .. help .. ??
source to share
Add handlers unobtrusively from your script. Something like:
function addHandler(etype, el,handlerFunction){
if (el.attachEvent) {
el.attachEvent('on' + etype, handlerFunction);
} else {
el.addEventListener(etype, handlerFunction, false);
}
}
var myButton = document.getElementById('mybutton');
addHandler('click', myButton, clicker);
addHandler('click', myButton, clicker1);
source to share
Yes you can if you attach an event listener: IE , other browsers .
Just keep in mind that both of them will not end at the same point, and it would be possible to "cut" if the site is redirected, before the second function is executed.
In addition, in this case, I would set a CSS class to the tag that contains both #downloadoverlay
, and so #downloadbox
. Instead of accessing the object directly style
.
source to share