Forum Moderators: open

Message Too Old, No Replies

Control Popup Window

popup window properties from asp

         

bphoward1

9:50 pm on Jul 24, 2004 (gmt 0)

10+ Year Member



My ASP page uses the following code to launch a popup window and pass a variable to it:

<form action="popup.asp" target=new method="post"
<input type="hidden" name="item" value="item">
</form>

The popup.asp page loads as expected and passes the variable, so the fundamentals are working just fine. However, I'd like to further customize the popup.asp window so that it's a bare-bones window (i.e., no toolbars, menubars, etc.). I'm told such customization must be done via javascript within the requesting page. I've seen one example where the programmer used the onsubmit event within the form to specify the popup window properties. Unfortunately, this only creates two popups when I tried it. Can anyone set me straight here? I just want one popup without all the extra stuff.

Best Regards,
B

RonPK

10:28 am on Jul 25, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



You'll probably need to add 'return false' somewhere. That should prevent the browser from submitting the form after you've already done that in your script.

<form action="popup.asp" target="_blank" onsubmit="yourfunctionhere(); return false;">

Rambo Tribble

3:25 pm on Jul 25, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Alternatively, and with the reservation that it will not function if JS is off, you can make the action attribute's value something like:

"javascript:window.open('popup.asp','','scrollbars=no');"

bphoward1

3:51 pm on Jul 25, 2004 (gmt 0)

10+ Year Member



RonPK,

I added return false to the onsubmit function call, as shown below, and that prevented the duplicate browser. Unfortunately, it eliminated the browser I expected from the action attribute, which is where the hidden variables are being passed:

<form action="popup.asp" target="_blank" method="post"
onsubmit="window.open('popup.asp','','menubar=no,toolbar=no'); return false">
<input type="hidden" name="item" value="item">
</form>

As a result, popup.asp appears in a window without menu or toolbars (good), but that page isn't receiving the hidden form value that I need to pass to it (bad). Basically, I need to use the action attribute to pass the hidden variable to popup.asp while retaining the ability to customize the window properties.

Rambo Tribble,

I tried setting the action attribute to the sample you provided, but that also prevents the passing of the hidden variable.

If either of you have any other ideas, I'd be eternally grateful.

B

RonPK

4:50 pm on Jul 25, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



You'll need a bit more script to perform the submit. Put it in a function, +/- like this:

<script type="text/javascript">
function submitmyform(f) {
f.target = 'foo';
window.open('',f.target,'menubar=no,scrollbars=no,width=300,height=200');
f.submit();
return false;
}
</script>

[..]

<form action="popup.asp" target="_blank" onsubmit="return submitmyform(this);">

[..]

That should be it!

bphoward1

5:04 pm on Jul 25, 2004 (gmt 0)

10+ Year Member



RonPK,

Brilliant solution to my dilemma! Popup.asp now appears without the menu/toolbars and still receives the hidden form values being passed to it!

I've scoured the Web for two days looking for this fix. Thanks for saving my weekend!

Sincerely,
B

bphoward1

5:07 pm on Jul 25, 2004 (gmt 0)

10+ Year Member



Oh, one more question for RonPK...what does "foo" really represent in your function?

function submitmyform(f)
{
f.target = 'foo';
window.open('',f.target,'menubar=no,scrollbars=no,width=550,height=325');
f.submit();
return false;
}

RonPK

5:37 pm on Jul 25, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Glad I could help, B.

> f.target = 'foo';

It changes the form's target from '_blank' to 'foo'. I guess you can leave it out if you replace the target in the form tag with 'target="foo"'. Haven't tested that, though.

Rambo Tribble

5:49 pm on Jul 25, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



It might be better to keep the target="_blank", for those who have JavaScript turned off.

bphoward1

7:54 pm on Jul 25, 2004 (gmt 0)

10+ Year Member



RonPK,

Got it...thanks again.

Rambo,

Do you mean change the target value to _blank within the function, or in the <form> tag on the requesting page? I've still got it in the requesting page as follows:

<form action="popup.asp" target="_blank" method="post" onsubmit="return submitmyform(this);">

Is the target doing anything in the <form> tag if it's already specified as "foo" within the function?

Forums Forever

B

Rambo Tribble

8:40 pm on Jul 25, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



I mean, if you keep it as part of the requesting page's form tag, and the user doesn't have JavaScript functioning, the page will default to its old type of result. If you change the target in the form to "foo", and JS is off, you will get an error because foo won't exist to serve as a target.

bphoward1

9:17 pm on Jul 25, 2004 (gmt 0)

10+ Year Member



Got it.

I left the _blank in the <form> tag, so I'm covered.

Thanks,
B