【index.html】编码:
代码语言:javascript复制<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<title>Document</title>
</head>
<body>
<iframe id="fr1" frameborder="1" style="width: 800;height:150px"></iframe>
<p>
<input type="text" name="userName" id="userName" placeholder="请输入姓名">
</p>
<p>
<input type="text" name="info" id="info" placeholder="请输入信息">
</p>
<p>
<input type="button" value="发送" onclick="sendMsg()">
</p>
<script>
function sendMsg() {
var userName = document.getElementById("userName").value;
var info = document.getElementById("info").value;
var url = "index.php?userName=" userName "&info=" info;
document.getElementById("fr1").src = url;
}
</script>
</body>
</html>
【index.php】编码:
代码语言:javascript复制<?php
$userName=$_GET['userName'];
$info=$_GET['info'];
var_dump($userName,$info);
?>
效果如下: