HEllo,

Does this look ok:

<a href="directlinktopurchasepage" target="_blank" onclick="return loadBuyPopup()">Buy Now</a>

function loadBuyPopup() {
 //do something
 return false;
}

Ideally I want the popup to load, but just incase the JS fails (i.e. it may load slowly and the user is in a hurry), then it should still allow the user to purchase using an ugly page.

Will this work in all browsers or am I missing something?

有帮助吗?

解决方案

Yes you are right. If the browser does not support JS, then the normal link (also the href) is going to be used for the link. Otherwise the onclick JS function will be called.

其他提示

Assuming that the non-js page is available at directlinktopurchasepage then this will work. The new page will open in a new tab\window due to the target="_blank".

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top