当前位置:Gxlcms > PHP教程 > php通过iframe实现局部刷新iframe刷新iframesrc获取iframe中的元素

php通过iframe实现局部刷新iframe刷新iframesrc获取iframe中的元素

时间:2021-07-01 10:21:17 帮助过:23人阅读

reg.html
reg.html页面中有个iframe标签,通过iframe去请求php校验用户名是否可用。

<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

header("content-type:text/html;charset=utf-8");
$username  = $_GET['username'];

if($username == 'admin')
{
    $msg = '对不起,用户名已被使用!';
}else
{
    $msg = '恭喜!该用户名可以使用。';
}


echo<<?>

html iframe,iframe用法,iframe 自适应高度,iframe 滚动条,iframe调用父页面方法,iframe 跨域,iframe 刷新,iframe src,获取iframe中的元素

').addClass('pre-numbering').hide(); $(this).addClass('has-numbering').parent().append($numbering); for (i = 1; i <= lines; i++) { $numbering.append($('
  • ').text(i)); }; $numbering.fadeIn(1700); }); });

    以上就介绍了php通过iframe实现局部刷新,包括了iframe方面的内容,希望对PHP教程有兴趣的朋友有所帮助。

  • 人气教程排行