Cross-domain form submission status in disguise judgment code _javascript skill

Source: Internet
Author: User
Turn a bend to think, if you can get the IFRAME inside the page information, then can not get the time, do not explain the form has been submitted it ~
We found that Baidu's bid on the lower right corner of the information, but also the use of this method to judge, we can refer to the next.
Example:

Test.html:
Copy Code code as follows:

<body style= "background: #a7a7a7;" >
<iframe id= "Testiframe" name= "Testiframe" ></iframe>
<form method= "POST" action= "http://www.test.com/testaction.php" target= "Testiframe" name= "Testform" >
<input type= "text" name= "dddd" ><input type= "Submit" value= "ddd" name= "submitbtn"/>
</form>
</body>
<script>
Document.testform.onsubmit = function () {
Document.testform.submitbtn.disabled = true;
Submitmonitor ();

}
function Submitmonitor () {
try{
var hash = document.getElementById (' Testiframe '). ContentWindow.location.hash;
SetTimeout (submitmonitor,100);
catch (e) {
document.getElementById (' testiframe '). src = "About:blank";
document.testform.submitbtn.disabled = false;
}
}
</script>

Note that the following code is Cross-domain, not under a domain name
testaction.php
Copy Code code as follows:

<?php
Sleep (5);
echo $_post[' dddd '];
?>

Disadvantages:
This drawback is also very obvious, if it is 404,403,500 errors, it will be mistaken for a successful submission.
Therefore, please note: This method is a research, pioneering thinking.
This is Baidu's judgment code.
Copy Code code as follows:

var sfmesstimes;
function Sfmesssubmitmonitor () {
try{
var hash = sf_mess_lib.getelement (sf_mess_frame_id). ContentWindow.location.hash;
Sfmesstimes + +;
if (Sfmesstimes > 50) {
alert (Sf_mess_msg.fail);
Sf_mess_lib.getelement (sf_mess_submit_id). Disabled = false;
for (var i = 0, L = sf_mess_cols.length i < l; i++) {
document.getElementById (Sf_mess_prefix + sf_mess_cols[i].idname). Disabled = false;
}
} else {
SetTimeout (sfmesssubmitmonitor,100);
}
catch (e) {
Sf_mess_lib.getelement (sf_mess_frame_id). src = "About:blank";
alert (sf_mess_msg.success);
Sf_mess_lib.getelement (sf_mess_submit_id). Disabled = false;
for (var i = 0, L = sf_mess_cols.length i < l; i++) {
var inputcfg = sf_mess_cols[i];
var Inputel = document.getElementById (Sf_mess_prefix + inputcfg.idname);
inputel.disabled = false;
Inputel.value = Filtinnertip (Inputcfg.innertip);
}
}
}

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.