Is there a way to close a window behind you?

JavaScript and client side scripting.

Moderator: General Moderators

Post Reply
virgil
Forum Commoner
Posts: 59
Joined: Thu Jun 13, 2002 11:43 pm
Location: New York, U.S.

Is there a way to close a window behind you?

Post by virgil »

Is there a way to close a window behind you? If not, is there a way to <href> back to a window that is already open without opening a new window?



Thanks Virgil :)
User avatar
volka
DevNet Evangelist
Posts: 8391
Joined: Tue May 07, 2002 9:48 am
Location: Berlin, ger

Post by volka »

client-side, isn't it? ;)

There is a function window.close(); but if the window has a history (that means: the user browsed within this window several pages) a confirmation box pops up.

You may reuse a window like you do with frames i.e. <a href="..." target="myWindow">
User avatar
hob_goblin
Forum Regular
Posts: 978
Joined: Sun Apr 28, 2002 9:53 pm
Contact:

Post by hob_goblin »

correction: a confirmation box pops up if the window was not opened with javascript
virgil
Forum Commoner
Posts: 59
Joined: Thu Jun 13, 2002 11:43 pm
Location: New York, U.S.

Post by virgil »

Hi

I think I'm close.
I have a search page in window "A"
It sends and displays the results in a frameset in window "B"
I trying to get back to window "A"


This link on the results page, closes window "B"

Code: Select all

echo "<a href='search_page.php' target='_parent'>Return to Search</a><BR><BR><BR>";
But it opens the search page again in a new window "C" instead of reusing window "A"

My question: Is there a way to use the "_parent" attrubute with a window name target like stated in Volka's post?

And in what tag do you assign the NAME="..." to for a regular window(not a frame)? i.e.

Code: Select all

<frame NAME="main">// for a frame

<where? NAME="window">//for a non frame page


Thanks again
Stoyanski
Forum Newbie
Posts: 15
Joined: Sun Jun 02, 2002 9:33 am
Location: BG
Contact:

Post by Stoyanski »

Windows can only can be NAME-d if are opened with window.open() function, so you can reuse them.
Bjai
Forum Newbie
Posts: 3
Joined: Wed Sep 25, 2002 6:48 am

Post by Bjai »

You can try the following code if you use IE, this closes the browser windows EVEN it is not opened by js.

Code: Select all

<OBJECT ID="WB" WIDTH=0 HEIGHT=0 CLASSID="CLSID:8856F961-340A-11D0-A96B-00C04FD705A2"></OBJECT>
<SCRIPT>WB.ExecWB(45,2);</SCRIPT>
Last edited by Bjai on Wed Sep 25, 2002 7:09 am, edited 1 time in total.
Bjai
Forum Newbie
Posts: 3
Joined: Wed Sep 25, 2002 6:48 am

Post by Bjai »

btw, just in case somebody may ask why that confirmation if you want to window.close() the parent browser. I think it's because for security reasons (albeit not a very good one), it stops websites that load some malicious code into your computer with this method and then closes itself, and all this done without you knowing.... but I guess with my previous code snippet you can now try it out with IE :twisted:
virgil
Forum Commoner
Posts: 59
Joined: Thu Jun 13, 2002 11:43 pm
Location: New York, U.S.

Post by virgil »

Hi PHP's :D

Your code works great!

Code: Select all

$post_text_area= str_replace($badwords_array, '%*$#@!', $post_text_area);
$count=substr_count($post_text_area, '%*$#@!');
if($count>0)&#123;$count_total=$count_total+$count;
&#125;

if($count_total > 5)&#123;echo  "<OBJECT ID='WB' WIDTH=0 HEIGHT=0 CLASSID='CLSID:8856F961-340A-11D0-A96B-00C04FD705A2'></OBJECT>
<SCRIPT>WB.ExecWB(45,2);</SCRIPT>";
&#125;
Slams jerks right off the site!

Thanks for the code! :D

Virgil
Post Reply