我想使用 javascript 从我的网站提交另一个网站提交按钮,这可能吗..?我的代码如下:
<script type="text/javascript">
function formSubmit() {
document.getElementById("form1").submit();
}
</script>
<form name="form1" method="post" action="http://XXXXX/Login.aspx?ReturnUrl=%2fdefault.aspx?" id="form1" >
<input type="hidden" name="NewCorporateId" id="NewCorporateId" value="XX" />
<input type="hidden" name="UserName" id="UserName" value="XXXX" />
<input type="hidden" name="Password" id="Password" value="XXXX" />
</form>
<form name="form2" id="form2" method="post>
<a href ="javascript:formSubmit()">Click here</a>
</form>
最佳答案
Specified URL opened fine in new tab and button not submitted in that site. That site contain the one submit button and username and password text filed.. I have username and password value.. So i try to submit the button in referring site from my website.
有可能,邮政代码是正确的,但是因为您在 aspx 页面上发布 Login.aspx
,aspx 页面会防止发送数据即不是来自同一站点并添加了哈希代码的控件。还有页面的 ViewState 以及 aspx 添加的其他隐藏参数 - 因此您的调用将失败。
与处理 login.aspx 页面的人员联系,为您提供某种登录方式 - 而不是直接通过页面登录。
相关: What is the purpose of __EVENTVALIDATION __VIEWSTATE in aspx?
关于javascript - 从网站提交另一个网站提交按钮,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/37805512/