Sunday, May 12, 2024
98
rated 0 times [  105] [ 7]  / answers: 1 / hits: 35924  / 15 Years ago, fri, july 17, 2009, 12:00:00
document.click = check;

function check(e)
{
var obj = document.getElementById('calendar_widget');

if (obj != 'null')
{
if (e.target.id != 'show_calender')
obj.style.display='none';
}
}


Error is in Internet Explorer: e.target.id is undefined.


More From » internet-explorer

 Answers
35

IE doesn't support the target property, they use srcElement instead.



Change:



if (e.target.id != 'show_calender')


to:



if ((e.target || e.srcElement).id != 'show_calender')


You may also need to add this to the beginning of your function:



if (!e) e = window.event


Your final code would look like this:



function check(e) { 
if (!e) e = window.event;
var obj = document.getElementById('calendar_widget');

if (obj != 'null') {
if ((e.target || e.srcElement).id != 'show_calender')
obj.style.display='none';
}
}

[#99110] Monday, July 13, 2009, 15 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
alexander

Total Points: 693
Total Questions: 114
Total Answers: 95

Location: Indonesia
Member since Wed, Jul 7, 2021
3 Years ago
;