If you can get the internal page information of iframe at the beginning, if you cannot get it, doesn't it mean that the form has been submitted ~
We found that Baidu's bidding information in the lower right corner is determined by this method. For details, refer.
Example:
Test.html:
Copy codeThe Code is as follows:
<Html>
<Head> <meta http-equiv = "Content-Type" content = "text/html; charset = gb2312"> <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>
</Html>
Note that the following code is cross-origin, not under a domain name
Testaction. php
Copy codeThe Code is as follows:
<? Php
Sleep (5 );
Echo $ _ POST ['dddd'];
?>
Disadvantages:
This disadvantage is obvious. If it is a 404,403,500 error, it will also be mistaken for a successful submission.
Therefore, please note: This method is a research method, which is used by NLP.
This section is Baidu's judgment code.
Copy codeThe Code is 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 );
}
}
}