问题
I'm attempting to add a donate button (because I like money) to my google chrome extension. I'm having trouble with it because the Chrome extension tries to open the paypal created donation button in the popup.html window. When I click the button, my extension just restarts and there is no donation window.
I have tried using chrome.tab.create() to try to make it open to a tab but it doesn't seem to have any effect.
The code to the donation button is as follows:
<form action="chrome.tabs.create ({'url': 'https://www.paypal.com/cgi-bin/webscr'});" method="post">
<input type="hidden" name="cmd" value="_s-xclick">
<input type="hidden" name="hosted_button_id" value="XXXXXXXX">
<input type="image" src="https://www.paypalobjects.com/en_US/i/btn/btn_donate_SM.gif" border="0" name="submit" alt="PayPal - The safer, easier way to pay online!">
<img alt="" border="0" src="https://www.paypalobjects.com/en_US/i/scr/pixel.gif" width="1" height="1">
Any help with this would be great!
Thanks
回答1:
Try a link instead of a form: https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=xxxxxxx
回答2:
Instead of:
<form action="chrome.tabs.create ({'url': 'https://www.paypal.com/cgi-bin/webscr'});" method="post">
Try:
<form action="https://www.paypal.com/cgi-bin/webscr" target="_blank" method="post">
回答3:
To add on to PayPal_Robert: If you still want the PayPal donate image linked in there, try:
<a target='_blank' href='https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=xxxxxxxx'>
<image src="https://www.paypalobjects.com/en_US/i/btn/btn_donateCC_LG.gif" border="0">
</a>
Just change the hosted_button_id parameter to your own.
来源:https://stackoverflow.com/questions/7438292/paypal-button-for-google-chrome-extension