0
我有一個eventlistener需要運行,一旦運行,我需要重定向到另一個頁面。然而,當我在代碼中的任何地方添加一個window.location.href時,它會直接跳轉到重定向,而不會執行其他代碼。eventlistener後重定向到另一個頁面
當我註釋掉運行時,它重定向...
document.getElementById('save').addEventListener('click', function() {
/*
* since the stage toDataURL() method is asynchronous, we need
* to provide a callback
*/
stage.toDataURL({
callback: function (dataUrl) {
//window.open(dataUrl);
// Send the screenshot to PHP to save it on the server
var url = 'export.php';
//alert(url);
$.ajax({
type: "POST",
url: url,
dataType: 'text',
data: {
base64data: dataUrl,
yname: thename,
yemail: theemail,
company: thecomp,
twitter: thetwitter
}
});
}
});
}); //close listener
太棒了,謝謝你! – 2014-12-08 09:17:47