-1
我正在使用greasemonkey在現有網頁上操作表單。 (自動填充)Greasemonkey在表格打印結果後不再執行
表單的action屬性本身,一旦提交,它會在提交按鈕上打印成功消息。
我想要做的是,一旦表單被提交 - 我想重定向瀏覽器到另一個頁面。但這不適用於greasemonkey。什麼都沒發生。
我寫了一段代碼來檢測頁面何時提交,但在表單提交後無效。
getData("goingback"); //pulls the goingback data from database using ajax
if (goingback == "yes") {
window.location = "index.php";
} else {
//business as usual
// manipulate the form and get it ready for submission
sendPost("goback","yes"); // this function sends data to a php to be handled via ajax
//ajax stores the data in database
//the form is submitted using a timer and .click();
var submission = Math.floor(Math.random() * 10000) + 5000;
setTimeout(function() {
$('button[value="submit"]:first').click();
}, submission);
}
我該如何做到這一點?
在此先感謝
你如何設置「返航」的值? – Dexter 2013-02-10 14:13:26
通過ajax存儲在數據庫中(正確提交之前)並在頁面加載時通過ajax提取(應該在提交後發生) – 2013-02-10 14:14:22
'localStorage'應該完成這項工作,只記得清除變量。如果可能,建議檢查DOM。 – 2013-02-10 14:18:45