後執行一個功能我有這個輸入:如何完成的第一個
<button type="button" title="test" class="button btn-cart" onclick="productAddToCartForm.submit(this); redirectToCart();">OK</button>
我要在完成第一個productAddToCartForm.submit(this)
後,但沒有移動第一上執行redirectToCart()
,我指的是productAddToCartForm.submit(this)
應留在onclick按鈕。
function redirectToCart()
{
window.location.replace("http://stackoverflow.com");
}
如果有的話,添加'form' HTML和'submit'函數。 – sabithpocker
不,我沒有它只是一個花式框中的按鈕,誰調用了'productAddToCartForm.submit(this)'我需要的是在完成函數 – Prince
什麼是'productAddToCartForm'後重定向到另一個頁面?它是一個HTMLForm嗎?你也可以添加'submit()'函數定義嗎?普通的HTML表單提交會導致整個頁面重新加載,具體取決於表單的目標。你將不得不[爲其他行爲使用AJAX](https://developer.mozilla.org/en-US/docs/Learn/HTML/Forms/Sending_forms_through_JavaScript) – sabithpocker