<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <title>伪造Ajax</title> </head> <body> <input type="text"> <form id="f1" action="/fakeajax/" method="post" target="ifr"> <iframe name="ifr" id="ifr"></iframe> {# 当iframe加载时,也就是有返回值的时候 执行loadiframe() 模拟回调函数#} <input name="user" type="text"> <a onclick="submit_form()">提交 </a> </form> </body> <script> function submit_form() { document.getElementById(‘f1‘).submit() document.getElementById(‘ifr‘).onload=loadiframe#绑定事件 } function loadiframe() { var return_values=document.getElementById(‘ifr‘).contentWindow.document.body.innerHTML console.log(return_values) } </script> </html>
原文:https://www.cnblogs.com/wangtc/p/10773832.html