Paypal page to iframe

Here is my code:
<body onload = "document.forms.paypalform.submit();">
	<iframe src='about:blank' name='paypalframe' id='paypalframe' frameborder='1' height='500' width=100%'></iframe>
	<form name="paypalform" action="https://www.paypal.com/cgi-bin/webscr" method="post" target="paypalframe">
		a bunch of hidden input tags for Paypal...
	</form>
</body>

Open in new window

The Paypal page does not appear in the iframe

The code works fine without the target tag and it works fine with the form's target="_blank" but the iframe just remains blank with the form's target="paypalframe".

The code is in a php script.

What's the problem?
TIA
LVL 39
thenelsonAsked:
Who is Participating?
 
GaryConnect With a Mentor Commented:
Ok missed that
You cannot load PayPal in an iframe, its a security risk and they prevent it happening.
0
 
GaryCommented:
Question doesn't make sense.
The iframe has no source so of course it will be blank.
Your paypal code has nothing to do with the iframe
0
 
thenelsonAuthor Commented:
The form has a target tag: target="paypalframe"

See: http://www.w3schools.com/html/html_iframe.asp "Use iframe as a Target for a Link".
And http://www.w3schools.com/tags/att_form_target.asp "framename      The response is displayed in a named iframe"
0
 
thenelsonAuthor Commented:
Oh well, thanks.
0
 
thenelsonAuthor Commented:
How about a followup question:
Using target="_blank"; when I submit the form with a button, the Paypal page loads into a new tab. When I submit the form with the onload event, the Paypal page loads into a new window. Any way to automatically submit the form to a new tab?
0
All Courses

From novice to tech pro — start learning today.