如何将值从一个html页面传递给另一个html页面javascript?

Raj*_*Raj 6 html javascript

如何将值从一个html页面传递到另一个html页面javascript

例如:

Page1.html页面

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html>
<head>
  <title>arasu</title>
  <style type="text/css">
  #popupbox{
  margin: 0; 
  margin-left: 40%; 
  margin-right: 40%;
  margin-top: 50px; 
  padding-top: 10px; 
  width: 20%; 
  height: 150px; 
  position: absolute; 
  background: #FBFBF0; 
  border: solid #000000 2px; 
  z-index: 9; 
  font-family: arial; 
  visibility: hidden; 
  }
  </style>
  <script language="JavaScript" type="text/javascript">
  function login(showhide){
    if(showhide == "show"){
        document.getElementById('popupbox').style.visibility="visible";
    }else if(showhide == "hide"){
        document.getElementById('popupbox').style.visibility="hidden"; 
    }
  }
  </script>
</head>
<body>
<div > 
<form name="login" action="AgaramAnimation.html" method="get">
<center>Username:</center>
<center><input name="username" size="14" /></center>
<center>Password:</center>
<center><input name="password" type="password" size="14" /></center>
<center><input type="submit" name="submit" value="login" /></center>
</form>
</div> 
</body>
</html>
Run Code Online (Sandbox Code Playgroud)

在这里我输入两个值用户名和密码,当我点击提交按钮时,弹出窗口将关闭,值传递给下面给出的另一个页面java脚本.

Page2.html

function gettingvalues()
         {            
            var connection = new ActiveXObject("ADODB.Connection");
            var connectionstring = "Data Source="";Initial Catalog="";User ID="";Password="";Provider=""";
            connection.Open(connectionstring);
            var rs = new ActiveXObject("ADODB.Recordset");
            rs.Open("select * from logindetails where username='" **+ username +** "' and password= '" **+ password +** "'", connection);
            if (!rs.eof) {
                document.getElementById("").innerHTML = "";   }
            else {
                alert('please enter valid username and password');
            }
            connection.close;
        }
Run Code Online (Sandbox Code Playgroud)

请帮助我..........

JB *_*zet 0

如果用来Main.html打开,那么 Popup.html 页面可以使用 来引用其打开的窗口(的窗口)。因此,它可以调用使用中定义的回调函数Popup.htmlwindow.open()Main.htmlwindow.openersetCredentialsMain.html

window.opener.setCredentials(...);
Run Code Online (Sandbox Code Playgroud)

例子:

在 Main.html 中:

// callback function called by the popup
function setCredentials(login, password) {
    // do what you want with the login and password
}
Run Code Online (Sandbox Code Playgroud)

在 Popup.html 中

// function called when the form is submitted
function login(login, password) {
    window.opener.setCredentials(login, password);
    window.close();
}
Run Code Online (Sandbox Code Playgroud)