Link to home
Start Free TrialLog in
Avatar of bobrossi56
bobrossi56

asked on

Close HTML page with close button, no confirmation dialogue

I have a webpage (page A) that has a link on it to open another webpage (page b) using _blank as target. I want to add a close button on page b. I tried this javascript code:
<form method="post">
<input type="button" value="Close Window"
onclick="window.close()">
</form>
It works, but it displays the dialogue box "Are you sure you want to close this window"?. I want to have the close button but I DON'T want it to bring up this YES/NO question, I just want it to close the window. Is this possible?
thx experts...BobR
Avatar of Dave Baldwin
Dave Baldwin
Flag of United States of America image

<input type="button" value="Close Window" onclick="window.close()">

Firefox says: "Warning: Scripts may not close windows that were not opened by script."  In Chrome and Safari it does nothing.  In Opera it does close the window.
Avatar of bobrossi56
bobrossi56

ASKER

I am missing your point Dave.

Most people I know are using IE8, so is it possible to put a close button that doesn't ask you any questions no matter the browser?
its browser dependant browser message.you cannot avoid this message.
if you see the gmail also if you close the window it will give you same message.
if you dont want message try creating child window using CSS .
"Are you sure you want to close this window"?.

above message will come in IE when user close window

in FF you will get another message.
in chrome i dont think you will not get any message.

but as you said most users will use IE so you cant avoid that message.

so instead of opening browser window try to create child window using css and put close button at the top(X);
The child window sounds like the way to go, problem is I have never done that and have no idea HOW to do it. CSS has never been my forte. Any pointers would be appreciated.
thx
or you can try jquery dialog
Most people I know use anything but IE.  My point was that it is blocked in those other browsers.
The jquery seems to be what I am looking for, but I have never used it before. I put the code in my HTML page, but when I click the link to that page it still brings up a completely new page with the dialogue box inside the page, so now you still have to close the page. Is there a way to just bring up the jquery dialogue box without bringing up another html page. All I am trying to do is bring up a pop-up message...I was using overlib code to do this but I ran into a problem with it and cannot get any support. In a perfect world when someone clicked (or moused over) a word on my webpage, a small dialogue box would pop up with a message. Since I couldn't get overlib to work the way I wanted, I figured I would just do it with a new HTML page, but wanted to put a close button on it. Now that I see jquery, I would rather just "pop" that type of dialogue box up and let them click the X in the upper right corner.
thx folks...
so you are using jquery dialog box.
Ya, I took the code from the jquery page and pasted it in my HTML page, I like the look/feel of the box but don't want it inside another web page. Can it just pop up and not be embedded in a webpage?
if you jquery dialog box you will see X in the upper right corner.if user wants he can click that and close the window.
I am not getting the impression chaituu that you understand my question. Your answer does not address my question at all. I want the jquery dialogue box to "POP UP" and not be inside another webpage. Don't know how to do that, or if it is even possible.
if you use jquery dialog that dialog box inside with another webpage only.if you use window.open then its is two separate windows(one parent,other one child);

what is you problem if you open dialog box inside web page.
Bringing up another webpage is too messy just to show site visitor a quick message.
ASKER CERTIFIED SOLUTION
Avatar of bobrossi56
bobrossi56

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
you should have told me before that just putting alert message;we should have post yesterday itself.;

you should have spefically told us to put some alert message.we thought you want some kind of child widnow to display some text boxes etc..

any way you solved your problem.next problem be specific to your problem.
True, I wasn't as clear as I should have been in my initial post, but I did VERY specifically state what I was tryiing to do in my 12/21/11 06:53 AM, ID: 37319824 post, specifically stating:

"[ All I am trying to do is bring up a pop-up message ]"

Perhaps that wasn't understood.
I accepted my own solution as it was exactly what I needed. I figured it out myself.
yes may be.it should have stated pop up error message or alert message.any way leave it .