Discussion Locked

how do i write script(vb, java) to close

0 helpful
9 replies
Closed to new repliesThis discussion is closed. It stays readable, but it takes no new replies.

1. i'd like to run a script to close the current opened window(browser)
this is the code i tried
javascript:self.close()
but there is a message pop up confirming if i really want to close the window, how would i do to get rid of this confirmingmessage(i did write with even onclick).

2. is there anyway to call java script which is not in the even. for example if user came
i got one page when user click the link to another web page, which is open new windows,
with this new window i would check something
if the checking is not match i just want this new window to be closed, how would i implement java script (or vbscript or both) to do the task for me

thanks in advance for any help

9 replies

by ksdaya

I have faced a similar problem before, and would like to share an interesting info (related to the first point).

The confirmation message that pops-up is a property of the browser. So, we cannot handle this problem programmatically. However, there have been occasions where some browsers don't display this confirmation message!

by ksdaya

I have faced a similar problem before, and would like to share an interesting info (related to the first point).

The confirmation message that pops-up is a property of the browser. So, we cannot handle this problem programmatically. However, there have been occasions where some browsers don't display this confirmation message!

I would like you to please explain the second point though.. It's not clear !

by mit

thanks a lot for the answering, um for the second question,
usually if we wanna refer the java script (as far as i know) we had to write the code in even
such as click even, enter, mouse over and so on. my question is, is there any way ifwe could just call the script
without puting the call routine in any even, i am writing asp, after the user
open the brower i'd like to check the code like this
if a = true then
call the script
else
do something else
end if
hope i don't make it more confusing

thanks again for your help

by al_<al

Any window that has NOT been opened by a JavaScript cannot be closed without the pop-up message. This is a security measure adopted to prevent such abuses as the email bomb where a click closes down the current browser session. The way to get aroundthis problem is call window.open(), do your business in that window and then call close() on that window or window variable. For example:

You can now close the window that just opened. Try it:

close window

As for question 2, most likely you will have to use VB or ASP or whatever to perform the checking, but once that is done, simply output the appropriate JavaScript to close the window (assuming the window has been opened previously by a JavaScript):

<%
If Request("appV") = "2.0" Then Response.Write("")
Else
[do something else]
End If
%>

Hope that helps

Al

This discussion is closed to new replies.