简体   繁体   English

在浏览器地址栏中写入JS代码的表单自动提交问题

[英]Issue with Form Auto-Submit with JS code written in browser's address bar

I am kind of newbie with JavaScript and web application programming. 我是JavaScript和网络应用程序编程的新手。 I am trying to create an "Auto Login" utility that will fill the UserName/PWD fields and will auto submit the information to server and will login to the application without user intervention. 我正在尝试创建一个“自动登录”实用程序,该实用程序将填充UserName / PWD字段,并将信息自动提交给服务器,并且无需用户干预即可登录到该应用程序。 This is same as another utility available called "RoboForm". 这与另一个称为“ RoboForm”的实用程序相同。 Due to some privacy issues I can't use this RoboForm or any third party utility for this purpose in my current organisation. 由于某些隐私问题,我不能在当前组织中使用此RoboForm或任何第三方实用程序来实现此目的。 So, I decided to create it on my own. 因此,我决定自己创建它。

This is what I am trying to do; 这就是我想要做的; Once I am on the login page of my application, I am writing below javascript code in the browser's address bar: 进入应用程序的登录页面后,我在浏览器的地址栏中写了以下javascript代码:

javascript:document.getElementById('Username').value='xyz';document.getElementById('Password').value='xyz_123';document.getElementById('Destination').value='TestDB';document.forms['Form1'].submit();

With this code everything is working fine except, form is not getting "Auto Submitted". 使用此代码,一切工作正常,除了表单没有“自动提交”。 I have to manually click on "Login" button to proceed further. 我必须手动单击“登录”按钮才能继续。

I did some research on google and got to know that the button id should not be "Submit". 我在Google上进行了一些研究,得知按钮ID不应为“提交”。 I verified that and the application I am trying to login has some diffrent id so that is not the problem. 我验证了这一点,并且我尝试登录的应用程序具有一些不同的ID,所以这不是问题。 I am not sure why the form is not getting "Auto Submitted". 我不确定为什么表单没有被“自动提交”。

Please note that the application I am trying to login to is a third party application and I do not have access to the source code. 请注意,我尝试登录的应用程序是第三方应用程序,我无权访问源代码。

Can anyone please help me with this? 谁能帮我这个忙吗? If any other alternatives are there to achieve the same, please suggest me. 如果有其他替代方法可以达到相同效果,请建议我。

Thanks! 谢谢! Swad 斯瓦德

If your form name is Form1 then the code for auto submit should be 如果您的表单名称为Form1则用于自动提交的代码应为

document.forms[0].submit();

or 要么

document.Form1.submit();

I found out the solution: 我找到了解决方案:

Instead of document.forms['Form1'].submit(); 代替document.forms['Form1'].submit(); use document.getElementById('cmdLogin1').click(); 使用document.getElementById('cmdLogin1').click();

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM