Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/422.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/jquery/81.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript 如何在html中将值从一个页面传递到另一个页面_Javascript_Jquery_Html_Css - Fatal编程技术网

Javascript 如何在html中将值从一个页面传递到另一个页面

Javascript 如何在html中将值从一个页面传递到另一个页面,javascript,jquery,html,css,Javascript,Jquery,Html,Css,我需要用html将值从一个页面传递到另一个页面。我只使用div类。其中显示了一个值。我需要将值传递到另一个页面并显示它 这是我的密码 <div class="scoredisplay"> <h3>SCORE</h3><button onclick="window.open('1.html','mywindow');">ok</button> <div class="displayno"> </div> 如果要将

我需要用html将值从一个页面传递到另一个页面。我只使用div类。其中显示了一个值。我需要将值传递到另一个页面并显示它

这是我的密码

<div class="scoredisplay">
<h3>SCORE</h3><button onclick="window.open('1.html','mywindow');">ok</button>
<div class="displayno">
</div>

如果要将值发送到另一页。您必须使用查询字符串。下面的代码执行相同的操作

<title>Passing Parameters between pages</title>

<script type="text/javascript" language="javascript">

function PassValue()

{

    var paramVal = "Hello Param";

    window.open("Default2.html?id=" + paramVal);

}

</script>

}

}


使用脚本中的上述代码获取发送的所有值的列表

既然您要导航到其他页面,我建议您使用两种方法,希望您不使用任何类型的服务器

首先-

您可以将变量存储在localStorage中,并根据需要调用。请参见此处的简单教程

第二-


您可以在URL本身中传递这个变量,并在下一页读取它

确保在发布前进行搜索;看看我需要通过javascript@user3894379您有标记jQuery,并且您已经在jQuery中编写了代码,或者您感到困惑或者让我们感到困惑您正在尝试做什么,哪里是successMessage id,哪里需要添加函数GetParamValue()
<title>Passing Parameters between pages</title>

<script type="text/javascript" language="javascript">

function PassValue()

{

    var paramVal = "Hello Param";

    window.open("Default2.html?id=" + paramVal);

}

</script>
<form id="form2">



    <input type="button" id="Button1"

        OnClick="PassValue();" value="Click Here" />



</form>
var parms = query.split('&');

for (var i=0; i >parms.length; i++)

{

    var pos = parms[i].indexOf('=');

    if (pos > 0) {

    var key = parms[i].substring(0,pos);

    var val = parms[i].substring(pos+1);

    alert(val);

   }