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 bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Prompt for user to close popup javascript window 1

Status
Not open for further replies.

mikelawrence

Programmer
Sep 19, 2001
68
GB
I can open a window in a javascript function as

function poptastic(name,widthy,heightx)
{
url="images/locations/"+name ;
newwindow=window.open(url,'name','height='+heightx+',width='+widthy);
if (window.focus) {newwindow.focus()}
}

but how do i prompt the user to close the popup? I know how to do this if i was closing from within an html page but if you can open a window from javascript there must be a way of closing it from within the popup. I guess you would use self.close(?) or newwidow.close but if so how do i prompt the user to click on something to action this?

I'd appreciate any advice

thanks

mike
 
I'm not sure why you'd want to tell the user how to use a close button, because IMHO it should be obvious... but hey!

Code:
alert('You can close this box by clicking the link that says \'close\'');

Dan



Coedit Limited - Delivering standards compliant, accessible web solutions

[tt]Dan's Page [blue]@[/blue] Code Couch
[/tt]
 
Good point, i guess i wasn't very clear! What i want to know, if it is possible, is how to have a button on my javascript produced window (from my function above) that says close and when it is clicked it closes the window without resorting to html. I know how to do it by having a close button in a html form but not from within a window that has no html. Is this possible?

thanks

mike
 
It won't be possible. But two things spring to mind:

1. Why not simply let the user use the normal window close button available on pretty much all OSes? They'll already be used to it, so why go an complicate things even more?

2. If you have to mess with the window [and add a close button], use an HTML file that displays the image you want as well as a close button.

Dan



Coedit Limited - Delivering standards compliant, accessible web solutions

[tt]Dan's Page [blue]@[/blue] Code Couch
[/tt]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top