onclick function works in IE6, not in FF1.5

M

Mike Scirocco

I use this function to detect an iframe button click. It works in IE6
but not in FF 1.5.

function setupbutton(){
var myiframe=document.getElementById('ifrmEditCategory');
var mybutton=myiframe.contentWindow.document.getElementById('btnClose')
//alert('myiframe '+myiframe+' mybutton '+mybutton);
mybutton.onclick=function() {btncloseclick()}
}

I call this after the iframe has been completely loaded, and make srue
the code can find the btnClose with the alerts... objects are shown for
both variables, so I'm sure it's finding the button.

Is there a way to make this code more robust for different browser?

Thanks,
Mike
 
M

Mike Scirocco

Mike said:
I use this function to detect an iframe button click. It works in IE6
but not in FF 1.5.

function setupbutton(){
var myiframe=document.getElementById('ifrmEditCategory');
var mybutton=myiframe.contentWindow.document.getElementById('btnClose')
//alert('myiframe '+myiframe+' mybutton '+mybutton);
mybutton.onclick=function() {btncloseclick()}
}

I call this after the iframe has been completely loaded, and make srue
the code can find the btnClose with the alerts... objects are shown for
both variables, so I'm sure it's finding the button.

Is there a way to make this code more robust for different browser?

This works in IE 6 and FF 1.5:

function setupbutton(){
var myiframe=document.getElementById('ifrmEditCategory');
var mybutton=myiframe.contentWindow.document.getElementById('btnClose');
if (window.addEventListener) {
mybutton.addEventListener('click', btncloseclick, true);
}else if (window.attachEvent){
mybutton.attachEvent('onclick',btncloseclick);
}else{
mybutton.onclick= btncloseclick();
}
}
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,580
Members
45,055
Latest member
SlimSparkKetoACVReview

Latest Threads

Top