reg.html
reg.html页面中有个iframe标签,通过iframe去请求php校验用户名是否可用。
<!DOCTYPE html><html><head><metacharset="utf-8"><title> iframe局部刷新</title></head><body><formmethod="post"action="">
用户名:<inputtype="text"id="uname"name='username' /><spanid="msg"style="color:red;"></span></form><iframeborder='0'width='0'height='0'id='myiframe' ></iframe><scripttype="text/javascript">//当用户名输入框失去焦点时让iframe请求check_reg.php
document.getElementById('uname').onblur = function(){if(this.value != '')
{
document.getElementById('myiframe').src = 'check_reg.php?username='+ this.value;
}
}
</script></body></html>check_reg.php
<?phpheader("content-type:text/html;charset=utf-8");
$username = $_GET['username'];
if($username == 'admin')
{
$msg = '对不起,用户名已被使用!';
}else
{
$msg = '恭喜!该用户名可以使用。';
}
echo<<<STR
<script>
window.parent.document.getElementById('msg').innerHTML = "$msg";
</script>
STR;?>
').addClass('pre-numbering').hide(); $(this).addClass('has-numbering').parent().append($numbering); for (i = 1; i ').text(i)); }; $numbering.fadeIn(1700); }); });
以上就介绍了php通过iframe实现局部刷新,包括了iframe方面的内容,希望对PHP教程有兴趣的朋友有所帮助。











