Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/242.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
Php 重定向,然后在另一页上运行函数?_Php_Html - Fatal编程技术网

Php 重定向,然后在另一页上运行函数?

Php 重定向,然后在另一页上运行函数?,php,html,Php,Html,所以我有代码: header("Location: ".$config['site_url']."index.php#login-box"); 这是我试图在用户未登录时触发jquery登录表单的html代码: <li><a class="log" href="#login-box"><span class="hover" style="opacity: 0;"></span></a></li> 但当它运行时,它所做

所以我有代码:

header("Location: ".$config['site_url']."index.php#login-box");
这是我试图在用户未登录时触发jquery登录表单的html代码:

<li><a class="log" href="#login-box"><span class="hover" style="opacity: 0;"></span></a></li> 
  • 但当它运行时,它所做的只是将#登录框添加到我的url的末尾,而不会触发#登录框href。我知道这是个很蹩脚的尝试,但有什么想法吗

    这是jquery脚本,如何正确地添加您提到的代码

                 $(document).ready(function() {
    $('a.login-window2').click(function() {
    
                //Getting the variable's value from a link 
        var loginBox = $(this).attr('href');
    
        //Fade in the Popup
        $(loginBox).fadeIn(300);
    
        //Set the center alignment padding + border see css style
        var popMargTop = ($(loginBox).height() + 24) / 2; 
        var popMargLeft = ($(loginBox).width() + 24) / 2; 
    
        $(loginBox).css({ 
            'margin-top' : -popMargTop,
            'margin-left' : -popMargLeft
        });
    
        // Add the mask to body
        $('body').append('<div id="mask"></div>');
        $('#mask').fadeIn(300);
    
        return false;
    });
    
    // When clicking on the button close or the mask layer the popup closed
    $('a.close, #mask').live('click', function() { 
      $('#mask , .login-popup').fadeOut(300 , function() {
        $('#mask').remove();  
    }); 
    return false;
    });
    });
                 </script>
    

    $(文档).ready(函数(){
    $('a.login-window2')。单击(函数(){
    //从链接获取变量的值
    var loginBox=$(this.attr('href');
    //在弹出窗口中淡入淡出
    $(登录框).fadeIn(300);
    //设置中心对齐填充+边框请参见css样式
    var popMargTop=($(loginBox).height()+24)/2;
    var popMargLeft=($(loginBox).width()+24)/2;
    $(登录框).css({
    “页边距顶部”:-popMargTop,
    “左边距”:-popMargLeft
    });
    //将遮罩添加到主体
    $('body')。追加('');
    $('面具').fadeIn(300);
    返回false;
    });
    //单击“关闭”按钮或遮罩层时,弹出窗口关闭
    $('a.close,#mask').live('click',function(){
    $('#掩码,.login popup').fadeOut(300,函数(){
    $(“#掩码”).remove();
    }); 
    返回false;
    });
    });
    
    下面是一个小片段,可以使用您提到的jQuery实现这一点:

    $(function(){
        $("a.login-window2").click(function(){
            //Getting the variable's value from a link
            var loginBox = $(this).attr("href");
            //Fade in the Popup
            $(loginBox).fadeIn(300);
            //Set the center alignment padding + border see css style
            var popMargTop = ($(loginBox).height() + 24) / 2;
            var popMargLeft = ($(loginBox).width() + 24) / 2;
            $(loginBox).css({
                "margin-top" : -popMargTop,
                "margin-left" : -popMargLeft
            });
            // Add the mask to body
            $("body").append("<div id=\"mask\"></div>");
            $("#mask").fadeIn(300);
            return(false);
        });
        // When clicking on the button close or the mask layer the popup closed
        $("a.close, #mask").live("click", function(){
            $("#mask , .login-popup").fadeOut(300, function(){
                $("#mask").remove();
            });
            return(false);
        });
        // Check the hash
        var hash = $(location).attr("hash");
        if(hash == "#login-box") {
            $("a.login-window2").click();
        }
    });
    
    $(函数(){
    $(“a.login-window2”)。单击(函数(){
    //从链接获取变量的值
    var loginBox=$(this.attr(“href”);
    //在弹出窗口中淡入淡出
    $(登录框).fadeIn(300);
    //设置中心对齐填充+边框请参见css样式
    var popMargTop=($(loginBox).height()+24)/2;
    var popMargLeft=($(loginBox).width()+24)/2;
    $(loginBox).css({
    “页边距顶部”:-popMargTop,
    “左边距”:-popMargLeft
    });
    //将遮罩添加到主体
    $(“正文”)。追加(“”);
    $(“#面具”).fadeIn(300);
    返回(假);
    });
    //单击“关闭”按钮或遮罩层时,弹出窗口关闭
    $(“a.close,#mask”).live(“单击”,函数(){
    $(“#掩码,.登录弹出窗口”).fadeOut(300,函数(){
    $(“#掩码”).remove();
    });
    返回(假);
    });
    //检查散列
    var hash=$(位置).attr(“hash”);
    如果(散列=“#登录框”){
    $(“a.login-window2”)。单击();
    }
    });
    

    将其放入
    index.php
    文件中,然后从
    if
    语句中运行代码。

    下面是一个小片段,它应该可以实现这一点,使用您提到的jQuery:

    $(function(){
        $("a.login-window2").click(function(){
            //Getting the variable's value from a link
            var loginBox = $(this).attr("href");
            //Fade in the Popup
            $(loginBox).fadeIn(300);
            //Set the center alignment padding + border see css style
            var popMargTop = ($(loginBox).height() + 24) / 2;
            var popMargLeft = ($(loginBox).width() + 24) / 2;
            $(loginBox).css({
                "margin-top" : -popMargTop,
                "margin-left" : -popMargLeft
            });
            // Add the mask to body
            $("body").append("<div id=\"mask\"></div>");
            $("#mask").fadeIn(300);
            return(false);
        });
        // When clicking on the button close or the mask layer the popup closed
        $("a.close, #mask").live("click", function(){
            $("#mask , .login-popup").fadeOut(300, function(){
                $("#mask").remove();
            });
            return(false);
        });
        // Check the hash
        var hash = $(location).attr("hash");
        if(hash == "#login-box") {
            $("a.login-window2").click();
        }
    });
    
    $(函数(){
    $(“a.login-window2”)。单击(函数(){
    //从链接获取变量的值
    var loginBox=$(this.attr(“href”);
    //在弹出窗口中淡入淡出
    $(登录框).fadeIn(300);
    //设置中心对齐填充+边框请参见css样式
    var popMargTop=($(loginBox).height()+24)/2;
    var popMargLeft=($(loginBox).width()+24)/2;
    $(loginBox).css({
    “页边距顶部”:-popMargTop,
    “左边距”:-popMargLeft
    });
    //将遮罩添加到主体
    $(“正文”)。追加(“”);
    $(“#面具”).fadeIn(300);
    返回(假);
    });
    //单击“关闭”按钮或遮罩层时,弹出窗口关闭
    $(“a.close,#mask”).live(“单击”,函数(){
    $(“#掩码,.登录弹出窗口”).fadeOut(300,函数(){
    $(“#掩码”).remove();
    });
    返回(假);
    });
    //检查散列
    var hash=$(位置).attr(“hash”);
    如果(散列=“#登录框”){
    $(“a.login-window2”)。单击();
    }
    });
    

    将其放入
    index.php
    文件中,然后从
    if
    语句中运行代码。

    这是代码中的错误

    使用:
    name=“#登录框”


    而不是:
    href=“#登录框”

    这是您的代码中的错误

    使用:
    name=“#登录框”


    而不是:
    href=“#login box”

    重定向是用
    标题(…)
    行完成的,而不是它下面的代码。重定向是用
    标题(…)
    行完成的,而不是它下面的代码。我可能是用错误的方式接近它的,我添加了jquery,我想知道如何将此代码添加到其中以使其工作使用脚本您必须使loginBox和mask出现,检查我的答案是否有更新(未测试,但应该可以工作)。我的url的末尾显示/index.php登录框,但仍然没有使用此代码触发。嗯,我这边的一切似乎都很好;你介意设置一个JSFIDLE或发送一个链接给我,这样我就可以查看代码了吗?啊,别担心。我会把你给我的信息和一些东西结合起来。谢谢。我可能用了错误的方法,我添加了jquery,我想知道如何将此代码添加到jquery中以使其工作使用脚本您必须使loginBox和mask出现,检查我的答案以获得更新(未测试,但应该可以工作).我的url的结尾显示了/index.php#login框,但它仍然不会触发此代码。嗯,在我这一端,一切似乎都很正常;你介意设置一个JSFIDLE或发送一个链接给我,这样我就可以查看代码了吗?啊,别担心。我会把你给我的信息和一些东西结合起来。谢谢