Forum Moderators: open

Message Too Old, No Replies

targetting location.href from pop-up

         

karlotta

1:59 pm on Jun 16, 2002 (gmt 0)



Hi!
I have a password protected page that is linked to from a pop-up window; when the right password is entered, the page opens... in the pop-up. I need it to open in a brand new full-size page, and I'm a javascript retard. Could anyone help?
Here's the code in the pop-up head:

function go(){
location.href="pass+".html";
}

(the name of the page is the password)
Please help?

tedster

6:45 pm on Jun 16, 2002 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Hi karlotta, and welcome to Webmaster World.

Javascript doesn't support forcing a maximized new window. One simple option would be to open the page [password].html in the original window - the one that spawned the pop-up window. That's a short line of code:

function go(){
newpage=pass+".html";
window.opener.parent.location=newpage;
}

If you want the pop-up to close, now that the password is entered, that takes one more line:

function go(){
newpage=pass+".html";
window.opener.parent.location=newpage;
self.close();
}

If you want to open the page in another brand new window (in addition to the original full window plus the popup - that makes 3 windows open) then the basic open.window() method will do the job. That opens a window with the size and other features that you specify, or it defaults to the browser's choice of size and features if you don't specify.

I'd suggest allowing the browser to decide, since many people who use large screens (1240 on up) don't browse with maximized windows and might not appreciate a fullscreen window being forced on them. Here's some code for that:

function go(){
newpage=pass+".html";
window.open(newpage)
}

If you really want to force the new page to as near to full screen as you can, then it gets more complex, because you must start taking measurements first. Let me know if that's really what you want and we will dig into it.

rewboss

4:57 am on Jun 18, 2002 (gmt 0)

10+ Year Member



It's really MSIE 5 that doesn't automatically maximize a new window when it's opened. That's actually not necessarily a bad thing: some Netscape users get annoyed when a full-sized window pops up because -- if their OS is fast enough -- they don't always notice that a new window has, in fact, opened, until either they close it, or try to use the Back button and wonder why it doesn't work.

karlotta

2:40 am on Jun 21, 2002 (gmt 0)



Thank you!
I used your option #2 - with the self-close script - and it works great.

bi3bi3

9:39 am on Aug 2, 2002 (gmt 0)



Talking about Location.href popup..
I need help!

In let's say www.example.com/index.html thereis a javascript open pop.htm and visitor input form, sending form data using PHP Script..

Now the problem, i just want to know how i can get first URL where the popup come or the caller page that call popup page?

so in my email will received..

Name :
Address :
Page Visit : [example.com...]
etc.

is it possible?

rewboss

11:07 am on Aug 2, 2002 (gmt 0)

10+ Year Member



In JavaScript, the URL of the window that caused the current window to open is stored as:

self.opener.location.href

(You could get away with writing simply opener.location)

I think that in PHP, it ought to be $HTTP_REFERER, which would be a lot easier to use in this case. I'm not sure if it works for popups in this way; I've never tried it.