Click to See Complete Forum and Search --> : one window opens, another closes?


Marg
05-31-2004, 02:46 PM
Hello,

I've got a page and I want it to be so that when somebody presses on the "enter" image.. a new window opens and the past window closes. Is this possible?


Thanks in advance,

Exuro
06-01-2004, 12:05 AM
Why don't you just have the new page open in the current window? It is really best to avoid opening new windows when possible. Many clients have the option blocked, and others are simply incapable if your method uses JavaScript.

As for your actual question, it can be done, but it's not worth it. You can achieve this using self.close(), but in most browsers this is either disabled, or it prompts the user first (which looks very bad).

As I noted before, opening new windows is best avoided. The fact that you are trying to close the original window as well makes the situation even worse. What if the user was previously visiting a different website (which they wish to return to), and they click a link to take a quick glipse at yours. When they click your "enter" image suddenly their window dissapears and they are no longer to return to the previous site using the Back button! If I were this user, I would probably be quite frustrated and more than likely never visit your site again.

But, hopefully you've already taken all of that into consideration and have a perfectly legitimate reason for wanting to do this, ne?

Marg
06-01-2004, 08:48 AM
Well, I was just wondering.

You see, I have this page with 2 frames.. the intro page. Is it possible to make it so that the.. main page doesn't open in the same frame as the "enter" image when it's pressed? Without having it open in a new window.


Thank you for the previous reply,

Exuro
06-01-2004, 12:35 PM
Originally posted by Marg
You see, I have this page with 2 frames.. the intro page. Is it possible to make it so that the.. main page doesn't open in the same frame as the "enter" image when it's pressed? Without having it open in a new window.

Ah, now that makes much more sense. And this I can help with! All you need to do is add a target="_top" to the anchor tag for your "enter" image:


<a href="main.html" target="_top">
<img src="enter.gif" alt="Enter the site" />
</a>

Marg
06-01-2004, 12:43 PM
Thank you.. very very much :)

I don't know if this is the right place, but.. do you know PHP? ;)

Exuro
06-01-2004, 04:57 PM
Originally posted by Marg
I don't know if this is the right place, but.. do you know PHP?

This wouldn't be the right place if you were making a new post, but as long as you have my attention anyway feel free to ask! :D

Marg
06-01-2004, 05:20 PM
:)

I will just PM you with the question, since this is the javascript board.. I realized.. lol

Thanks in advance,