Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

close page javascript doesn't work for firefox

Status
Not open for further replies.

photoxprt1868

Programmer
Jul 22, 2005
76
0
0
US
Hello,

does anyone know where I can find a script to close a page that works for both IE and firefox

This is what I'm currently using

Code:
<form>
<input type="button" value="Close This Page" onClick="javascript:window.close()">
</form>
 
That should work fine. Does it not work for you? WHat errors does it give? Which browser does it not work in (you don't say).

Try this anyway:

Code:
onclick="window.opener = self; window.close();"

Hope this helps,
Dan

Coedit Limited - Delivering standards compliant, accessible web solutions

[tt]Dan's Page [blue]@[/blue] Code Couch
[/tt]
 
Remember: only a page opened with Javascript can be closed (eg with the window.open function), it's not possible to close a window that was opened by a user.

mcvdmvs
&quot;It never hurts to help&quot; -- Eek the Cat
 
I ran in to a similar issue. I have the following code for an AJAX handler:

function handle() {
if (req.readyState == 4) {
// only if "OK"
if (req.status == 200) {
var myDiv = document.getElementById('list');
myDiv.innerHTML = req.responseText;
if (editWindow) {
editWindow.close();
}
}
else {
alert("There was a problem retrieving the XML data:\n" + req.statusText);
}
}
}

I know I'm using the lazy-man's way (innerHTML), but it's simple for what I'm doing. Anyway, what's going on is the user clicks an item and the page opens another window (window.open()). On the new window, the user edits the info for the item clicked. Upon submit, the new window is sent this code:

<script>
window.opener.refreshItems();
</script>";

which calls the AJAX function to refresh the list on the original page. The handler (above) is set to close the editItem window if it exists. In IE, the window closes right away. In FF, the window closes when I move the mouse over the window (not the title bar or toolbars, but the pane that displays the html).

I think it's weird that it does this, but that's what I'm getting.
 
It was working for IE, but not for firefox. I'll try your suggestions now.

Thank you very much
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top