Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Problem with Window.Open 1

Status
Not open for further replies.

tnsbuff

Technical User
Jan 23, 2002
216
US
Hi,

I have a little popup window that contains a form to login to a section. This popup does not contain a menubar or anything.

The problem is that after you login, the page that opens also does not have a menubar, etc. I forced the page you go to after logging in to maximize when it opens, but I don't know how to get the other features back.

Anyone?

TIA
 
Sounds like you need to open a new window and close the current one.

Programming today is a race between software engineers striving to build better and bigger idiot-proof programs, and the Universe trying to produce bigger and better idiots. So far, the Universe is winning. - Rick Cook (No, I'm not Rick)

fart.gif
 
>>Sounds like you need to open a new window and close the current one.<<

So, then I guess I would use an onSubmit function to open the window/url that the form is posting to, but will the values be passed to that page if I do it that way?

 
Yes

Programming today is a race between software engineers striving to build better and bigger idiot-proof programs, and the Universe trying to produce bigger and better idiots. So far, the Universe is winning. - Rick Cook (No, I'm not Rick)

fart.gif
 
Okay, I'm obviously doing something wrong. Here's what I have:

This is the tag that activates the function to open the popup:

[a href=&quot;javascript: openLogin()&quot;]View Demo[/a>]

and the function that opens the popup:

function openLogin(){
window.open('demo_login.html','Login','height=200,width=400,scrollbars=yes');
}


and this is the form's action tag (on the Login page) that activates the function that's supposed to open a new full size window and close the popup which contains the login form:

[form method=&quot;post&quot; action=&quot;Merchant2/merchant.mvc&quot; onSubmit=&quot;changeWin()&quot;]

and this is the function that doesn't work:

changeWin(){
window.open('Merchant2/merchant.mvc', 'Store');
Login.close();
}

What happens is that the page opens in the same little window instead of opening a new window.

Where'd I goof? :)
 
<form method=&quot;post&quot; action=&quot;Merchant2/merchant.mvc&quot; target=&quot;_blank&quot;>

On the new page

window.opener.close()

Programming today is a race between software engineers striving to build better and bigger idiot-proof programs, and the Universe trying to produce bigger and better idiots. So far, the Universe is winning. - Rick Cook (No, I'm not Rick)

fart.gif
 
You could also do it like this...

<script>
function subForm(){
formWin = window.open(&quot;&quot;,&quot;formWin&quot;,&quot;top=0,left=0,scrollbars=yes,resize=yes, address=yes,menubar=yes&quot;)
document.myForm.action=&quot;Merchant2/merchant.mvc&quot;
document.myForm.target = formWin
document.myForm.method = &quot;post&quot;
document.myForm.submit()
}
</script>

<form name=&quot;myForm&quot;>
..
..
..
<input type=button onClick=&quot;subForm()&quot; value=&quot;Submit&quot;>

Programming today is a race between software engineers striving to build better and bigger idiot-proof programs, and the Universe trying to produce bigger and better idiots. So far, the Universe is winning. - Rick Cook (No, I'm not Rick)

fart.gif
 
>>[form method=&quot;post&quot; action=&quot;Merchant2/merchant.mvc&quot; target=&quot;_blank&quot;]<<

<grrrrr> Why didn't I think of that?

So I didn't even need to mess with using a function to open a new window for the target page.

Question: I had to put the window.opener.close() line into a global header that affects every page in my store. Is that going to be a problem?

Thanks again. You get a star.;-)
 
If you want to check to see what the window.opener was first, it shouldn't cause a problem...

if (window.opener.location.href == &quot;loginPage.htm&quot;){
window.opener.close()
}

Programming today is a race between software engineers striving to build better and bigger idiot-proof programs, and the Universe trying to produce bigger and better idiots. So far, the Universe is winning. - Rick Cook (No, I'm not Rick)

fart.gif
 
This is (!fair).

I think mwolf has a sniffer in his browser....

if(user == 'give a star') { alert(&quot;Grab Thread&quot;); }

Just kidding.....

Thanks for sharing the tile puzzle.

2b||!2b
 
Thanks again mwolf00. It didn't appear to be causing a problem so far but it's good to know I can limit its effect by specifying what page I want to apply the code to.

Lrnmore ... you're funny! :)
 
Lrnmore-

I'm sure you know how it goes - sometimes you spend 2 days writting lines and lines of code and get a simple &quot;thank you&quot; (and sometimes not even that)

Other times you get a star for something relatively simple (thank you tnsbuff). You just post to help others.

BTW - I was able to finish the &quot;Easy&quot; tile puzzle in 80 clicks (that can't be very good). I would be VERY interested in anyone able to complete the &quot;Impossible&quot; puzzle...

Programming today is a race between software engineers striving to build better and bigger idiot-proof programs, and the Universe trying to produce bigger and better idiots. So far, the Universe is winning. - Rick Cook (No, I'm not Rick)

fart.gif
 
One more little problem.

Okay, the link to &quot;Login to Demo&quot; is on a sort of &quot;Welcome Page&quot;.

Normally, when someone uses the &quot;regular&quot; login, they are returned to this page, and there are links in the left border that they can navigate to (after logging in). After someone logs in to the demo from the &quot;popup&quot;, they are also sent to this page, except because I used target=&quot;_blank&quot; in the action tag of the popup form, it's opening up a new version of it, so now there are 2 of the same page.

Is there a way to send them back to the same original page, although with the page refreshed and now logged in, (which is how it would normally be after logging in from a full-sized page)

Does this make sense?

Thanks,

 
When I want to do that, have the login pop-up also be the form handler for the login (it references itself). Then I have that window close and refresh the window.opener. Something like this...

var closed = false;
function closeWin(message){
if (! closed){
window.resizeTo(20,20)
window.opener.focus()
if (message != &quot;&quot;){
window.opener.alert (message)
}

locName = window.opener.location.toString()
quesFound = locName.indexOf(&quot;?&quot;)
if (quesFound== -1){
locName = locName + &quot;?cbr=<%=cbr%>&quot;
}
else{
cbrFound = locName.indexOf(&quot;cbr&quot;)
if (cbrFound < locName.length - 13){
locName += &quot;<%=cbr%>&quot;
}
}
window.opener.location = locName
closed = true
self.close()
}
}

Programming today is a race between software engineers striving to build better and bigger idiot-proof programs, and the Universe trying to produce bigger and better idiots. So far, the Universe is winning. - Rick Cook (No, I'm not Rick)

fart.gif
 
Hmmm, you lost me on this one.

Does this go in the popup login form or the welcome page?

There's no querystring attached to the url either before or after logging in. It's not until a person is logged in and clicks on a category link in the navigation that a querystring is involved.

Could you explain what each line is doing in your example; then maybe I could adapt it to my situation.

Thanks a lot for your help.
 
Sorry, pasted the first example I could find...

welcome.asp
<%
if session(&quot;userID&quot;) <> &quot;&quot; then
'you can redirect
response.redirect &quot;welcome2.asp&quot;
'or you can alter this page
htmlOut = &quot;some info you only see when you log in&quot;
end if
%>
<script>
function logWin(){
window.open (&quot;login.asp&quot;,&quot;logWin&quot;)
}
</script>

<input type=button onCLick=&quot;logWin()&quot; value=&quot;Log In&quot;>



login.asp
<%
if request.serverVariables(&quot;HTTP_Method&quot;) = &quot;POST&quot; then
set rs = cn.execute(&quot;SELECT * FROM myTable where user = '&quot; & request(&quot;user&quot;) & &quot;' and pswd = '&quot; & request(&quot;pswd&quot;) & &quot;'&quot;)
if not rs.eof then
session(&quot;userID&quot;) = rs(&quot;userID&quot;)
%>
<script>
theURL = window.opener.location.href
window.opener.location = theURL
self.close()
</script>
<%
response.end
end if
end if
%>
<form action=&quot;login.asp&quot; method=&quot;Post&quot;>
<input name=user><input name=pswd><input type=submit>

Programming today is a race between software engineers striving to build better and bigger idiot-proof programs, and the Universe trying to produce bigger and better idiots. So far, the Universe is winning. - Rick Cook (No, I'm not Rick)

fart.gif
 
I can't use asp or php. The welcome page is dynamically created by the Miva Merchant script and has the .mvc extension.

That's ok. I'll just leave it as is for now.

Thanks again,
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top