1
pstrasma
Odd javascript window.open behavior
  • 2003/12/27 7:34

  • pstrasma

  • Just popping in

  • Posts: 24

  • Since: 2003/12/23


I am attempting to embed a HTML registration form as a content page. When submitted, this form opens up a new window to a Paypal shopping cart. Unfortunately, although I the page works perfectly when served as a straight HTML page, it changes behavior when put in as a XOOPS page in either TinyContent or WF-Sections. Instead of showing the proper paypal page, the pop-up window shows a XOOPS submission and then error. Any ideas on why this happens?

Here is the javascript code I'm using:

<SCRIPT LANGUAGE=JAVASCRIPT TYPE="TEXT/JAVASCRIPT">
function 
openWin() {
l=(screen.width-525)/2
t
=(screen.height-300)/2
a
=window.open('','paypal','width=525,height=300,left='+l+',top='+t);
document.forms[0].target='paypal';
setTimeout('document.forms[0].submit()',1000)
}
</
SCRIPT>

<
FORM target="paypal" action="https://www.paypal.com/cgi-bin/webscr" method="post">
<
input type="image" src="https://www.paypal.com/en_US/i/btn/x-click-but22.gif" border="0" name="submit" alt="Submit via PayPal" align="texttop" width="87" height="23" onClick="openWin()">
</
FORM>


If you'd like to take a look at the problem in action, here the WF-Section implementation: Failing Page

Here is a working version of the page, using TinyContent and an IFRAME to access the original page:
Work-around Page

Thanks in advance!

PS-it is safe to click the "Add to Cart" and "View Cart" buttons and open the shopping cart pop-up. Just don't go through the Paypal checkout unless you plan on donating money...

2
JackJ
Re: Odd javascript window.open behavior
  • 2003/12/27 14:37

  • JackJ

  • Community Support Member

  • Posts: 747

  • Since: 2003/8/31


Hello pstrasma

Your "failing page" cant be seen by unregistered users, perhaps you could change permissions in groups. I have a little hashed "framebrowser" module for download on my site, I find it useful for some wrapping some scripts or files in XOOPS without any internal hacking. I use it for Zina media streamer etc

regards

3
pstrasma
Re: Odd javascript window.open behavior
  • 2003/12/27 16:14

  • pstrasma

  • Just popping in

  • Posts: 24

  • Since: 2003/12/23


Ah, good call on those permissions. I'll open that up for the time being.

And thanks for the Framebrowser reference. It is helpful to see how others have tackled this problem. One still wonders what XOOPS is doing to mess with the target window...

4
JackJ
Re: Odd javascript window.open behavior
  • 2003/12/27 23:28

  • JackJ

  • Community Support Member

  • Posts: 747

  • Since: 2003/8/31


You appear to have two body tags, it looks like the head tags etc are unstripped.

Paste the following code into a text editor, and save it as an HTML file (no head and body tags)

Upload it into the HTML folder in wfsections and create your page from there through wfsections using the external HTML facility. This way no extra lines or code or table cells are inadvertantly added. (This may also work using wysiwyg, you could try it)

Assuming you have the wfsections that does not give "empty" errrors when you do it this way. (I have a version on my site for download which has this fixed) If you have the version with that problem just add a line of text in the wysiwyg and save, it should work. (It wont add the line of text)

Code:

<SCRIPT LANGUAGE=JAVASCRIPT TYPE="TEXT/JAVASCRIPT">
function openWin() {
l=(screen.width-525)/2
t=(screen.height-300)/2
a=window.open('','paypal','width=525,height=300,left='+l+',top='+t);
document.forms[0].target='paypal';
setTimeout('document.forms[0].submit()',1000)
}
</SCRIPT>

<DIV class=itemHead align=center><STRONG>Alumni Day 2004 Registration</STRONG></DIV>
<p>You can register for 2004 Reunion events online using PayPal or by calling
the IMSA Fund office at (630) 907-5040. Please note that no onsite registrations will be available.
The deadline to register is <STRONG>May 31, 2003!</STRONG>.&nbsp; <i>Register before March 31, 2003 for a 10% discount on all events.</i></P>
<table border="0" cellspacing="0" height="395">
<tr>
<td colspan=3 height="20" ><p><STRONG>Class Reunions</p></strong></td>
<td align="center" height="20"><i>Price</i></td>
<td ><i>Quantity</i></td>
</tr>
<tr><td colspan=5 height="1" ><hr size="1"></td></tr>
<tr>
<td width="415" colspan=3 height="20">Class of 1989 Reunion</td>
<td width="48" rowspan="2" align="center" height="46">$65</td>
<td width="163" rowspan="2" height="46">
<input type="text" size="2" name="quantity">
</td>
</tr>
<tr><td height="24">&nbsp;</td>
<td height="24" ><input type="hidden" name="on0" value="Meal Request"><i>Meal:</i>
<select name="os0"><option value="Meat">Meat
<option value="Veg">Vegetarian</select>
</td>
<td height="24"><input type="hidden" name="on1" value="Guest"><i>Guest Name:</i>
<input type="text" name="os1" maxlength="40"></td>
<input type="hidden" name="add" value="1"></form>
</tr>
<tr><td colspan=5 height="20" ><hr size="1"></td></tr>
<tr>
<td colspan=3 height="20">Class of 1994 Reunion</td>
<td rowspan=2 align="center" height="46">$50
<td rowspan=2 valign="middle" align="left" height="46">
<form target="paypal" action="https://www.paypal.com/cgi-bin/webscr" method="post">
<input type="text" size="2" name="quantity">
<input type="image" src="https://www.paypal.com/en_US/i/btn/x-click-but22.gif" border="0" name="submit" alt="Submit via PayPal" align="texttop" width="87" height="23" onClick="openWin()">
<input type="hidden" name="cmd" value="_cart">
<input type="hidden" name="business" value="imsafund@imsa.edu">
<input type="hidden" name="item_name" value="Class of 1994 Reunion">
<input type="hidden" name="amount" value="50.00">
<input type="hidden" name="image_url" value="http://piquant.us/imsa/images/logo.gif">
<input type="hidden" name="no_shipping" value="1">
<input type="hidden" name="return" value="http://piquant.us/imsa/modules/tinycontent/index.php?id=8">
<input type="hidden" name="cancel_return" value="http://piquant.us/imsa/modules/tinycontent/index.php?id=10">
<input type="hidden" name="cn" value="Comments">
<input type="hidden" name="currency_code" value="USD">
<input type="hidden" name="lc" value="US">
</td></tr>
<tr><td height="24">&nbsp;</td>
<td height="24"><input type="hidden" name="on0" value="Meal Request"><i>Meal:</i>
<select name="os0"><option value="Meat">Meat
<option value="Veg">Vegetarian</select>
</td>
<td height="24"><input type="hidden" name="on1" value="Guest"><i>Guest Name:</i>
<input type="text" name="os1" maxlength="40"></td>
<input type="hidden" name="add" value="1"></form>
</tr>
<tr><td colspan=5 height="20" ><hr size="1"></td></tr>
<tr>
<td colspan="3" height="20">Class of 1999 Reunion</td>
<td rowspan=2 align="center" height="46">$35
<td rowspan=2 height="46">
<input type="text" size="2" name="quantity">
</td>

</tr>
<tr><td height="24">&nbsp;</td>
<td height="24"><input type="hidden" name="on0" value="Meal Request"><i>Meal:</i>
<select name="os0"><option value="Meat">Meat
<option value="Veg">Vegetarian</select>
</td>
<td height="24"><input type="hidden" name="on1" value="Guest"><i>Guest Name:</i>
<input type="text" name="os1" maxlength="40"></td>
<input type="hidden" name="add" value="1"></form>
</tr>
<tr><td colspan=5 height="20" ></td></tr>

<tr>
<td colspan=3 height="20"><p><STRONG>General IMSA Activities</strong></p></td>
<td align="center" height="20"><i>Price</i></td>
<td height="20"><i>Quantity</i></td>
</tr>
<tr>
<td colspan=5 height="20"><STRONG><hr size="1"></strong></td></tr>
<td colspan=3 height="25">Alumni Day Faculty Lunch</td>
<td align="center" height="25">$10</td>
<td height="25"><input type="text" size="2" name="quantity">
</td>
<tr><td colspan=5 height="20" ></td></tr>
<tr>
<td colspan=3><p><strong>Submit Registration through PayPal </strong></p></td>
<td align="center"></td>
<td >
<form target="paypal" action="https://www.paypal.com/cgi-bin/webscr" method="post">
<input type="hidden" name="cmd" value="_cart">
<input type="hidden" name="business" value="imsafund@imsa.edu">
<input type="image" src="https://www.paypal.com/en_US/i/btn/view_cart.gif" border="0" name="submit" alt="Make payments with PayPal - it's fast, free and secure!" onClick="openWin()">
<input type="hidden" name="display" value="1">
</form>
</tr>
</table>

You should be able to change the page permissions back now.

I could have logged in I suppose? I am going senile I think..:)

regards

5
pstrasma
Re: Odd javascript window.open behavior
  • 2003/12/28 5:06

  • pstrasma

  • Just popping in

  • Posts: 24

  • Since: 2003/12/23


Thought I'd tried that approach, but you never know...

This time around with the copy/pasted code, the behavior improved somewhat. Basically what happens now is that the script opens the new window and very briefly displays the Paypal cart as desired. Then it switches back to a XOOPS site submission, redisplaying the form again in the small window. If I use the browser back in the pop-up window, it nicely goes back to the shoppping cart.

The change in behavior might also have something to do with the auto-login hack I applied before going back to this wf-sections issue.

So any ideas on this more isolated problem of the second page request occuring in the module-based page vs. the stand-alone page?

Thanks in advance!

6
pstrasma
Re: Odd javascript window.open behavior
  • 2003/12/28 5:09

  • pstrasma

  • Just popping in

  • Posts: 24

  • Since: 2003/12/23


Solved the problem! Live PayPal cart now embedded in WF-Sections here.

Solution was to change the OpenWin function from an OnClick in the submit button tag to an OnSubmit in the form tag. I also deleted the time delay -- can't even recall why that was needed originally. Current working code follows:

<SCRIPT LANGUAGE=JAVASCRIPT TYPE="TEXT/JAVASCRIPT">
function 
openWin() {
l=(screen.width-525)/2
t
=(screen.height-300)/2
a
=window.open('','paypal','width=525,height=300,left='+l+',top='+t);
}
</
SCRIPT>

<
form target="paypal" action="https://www.paypal.com/cgi-bin/webscr" method="post" onSubmit="paypal=openWin();paypal.focus();">

<
input type="image" src="https://www.paypal.com/en_US/i/btn/x-click-but22.gif" border="0" name="submit" alt="Submit via PayPal" align="texttop" width="87" height="23">https://www.paypal.com/en_US/i/btn/x-click-but22.gif"</a>
border="0" name="submit" alt="Submit via PayPal"
align="texttop" width="87" height="23"
onClick="openWin()">
</
FORM>

Login

Who's Online

168 user(s) are online (92 user(s) are browsing Support Forums)


Members: 0


Guests: 168


more...

Donat-O-Meter

Stats
Goal: $100.00
Due Date: May 31
Gross Amount: $0.00
Net Balance: $0.00
Left to go: $100.00
Make donations with PayPal!

Latest GitHub Commits