我创建了一个页面,其中包含用于用户名和密码的两个文本字段以及一个按钮。现在,当用户点击按钮时,我希望页面重定向到另一个网页,并将值(用户在我的页面上输入的内容)放在重定向的网页的文本字段上,这将要求相同的页面。现在我的网页是我创建的基本页面,但是当用户点击按钮时要重定向的页面将是一个实际运行的网站(我没有任何控制权)。语言与我使用的库是php,javascript,jquery,html,css。有没有办法让这种情况发生?.....提前感谢....... ..这是我的尝试......
<html>
<head>
<script type="text/javascript">
function load()
{
var user = document.getElementById("tx1").value;
var pass = document.getElementById("tx2").value;
// alert(user);
// window.location.assign('');
window.location="https://www.irctc.co.in/eticketing/loginHome.jsf?j_username="+user+"&password="+pass;
// window.location.href = '';
sessionStorage.user = user;
sessionStorage.pass = pass;
// alert(userid);
}
</script>
</head>
<body>
<div id="dv001">
<div id="dv11">
<h2 id="txt2">Sign in</h2>
<form>
<b id="txt3">Have an account? <br> Sign in here..</b>
<input type="text" id="tx1">
<input type="password" id="tx2" >
<!-- <a href="main_index.php"> -->
<input type="Button" id="bt1" value="Sign in" onclick="load()">
</form>
</div>
</div>
</body>
</html>
答案 0 :(得分:1)
当您导航到属于其他域的页面时,您无法通过页面中的JavaScript对该页面执行任何操作。它完全是另一个浏览器窗口(某种类型),您无权访问它。
唯一的可能性是网站使用$ _GET来填补它 形式。
所以,你可以用你网页上的少数参数填写[不在我的控制中]域名链接并导航。
答案 1 :(得分:0)
你需要的是这个,我已经测试了它并且工作正常
<form action="https://www.irctc.co.in/eticketing/loginHome.jsf" method="get">
<input type="text" name="j_username">
<input type="password" name="password">
<input type="submit" value="send">
</form>