HTML网页之间如何传值
展开全部
跨域就可以直接调用另一个页面的javascript函数,前提是知道另一个页面的引用方式,例如在当前页打开。
pass.html
<html>
<head>
<script>
var pass2_window;
function open_pass2 () {
pass2_window = window.open("pass2.html");
}
function call_pass2 () {
pass2_window.show_message("Hello World!");
}
</script>
</head>
<body>
<button onclick="return open_pass2();">
click me!
</button>
<button onclick="return call_pass2();">
click me!
</button>
</body>
</html>
pass2.html
<html>
<head>
<script>
function show_message (message) {
alert(message);
}
</script>
</head>
</html>
pass.html
<html>
<head>
<script>
var pass2_window;
function open_pass2 () {
pass2_window = window.open("pass2.html");
}
function call_pass2 () {
pass2_window.show_message("Hello World!");
}
</script>
</head>
<body>
<button onclick="return open_pass2();">
click me!
</button>
<button onclick="return call_pass2();">
click me!
</button>
</body>
</html>
pass2.html
<html>
<head>
<script>
function show_message (message) {
alert(message);
}
</script>
</head>
</html>
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询