Reputation: 53
After clicking close button
current window is not closing in Firefox
but its working fine in IE
function closeWin() {
var d=window.opener;
try {
var param="";
var winHref=d.document.location.href;
if(winHref.indexOf("?") > -1){
param=winHref.substr(winHref.indexOf("?"));
}
//d.document.location.href=d.document.forms[0].thankyouurl.value+'?'+param;
d.document.location.href=d.document.getElementsByName('thankyouurl')[0].value+'?'+param;
}
catch(e){}
finally{}
window.close();
return true;
}
<input type="button" name="Button" value="Close" onClick="return closeWin();">
Upvotes: 5
Views: 10485
Reputation: 3574
You can't close the page with window.close() in Firefox unless it is opened by a script. So you'll have to trick Firefox in thinking you opened it with a script. This would work:
function closeWindow() {
window.open('','_parent','');
window.close();
}
Now just call the closeWindow() whenever you want the window to close. This works in other browsers too.
Upvotes: 5