Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/406.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 javascript中的链接?_Php_Javascript - Fatal编程技术网

Php javascript中的链接?

Php javascript中的链接?,php,javascript,Php,Javascript,我的网站上有一个收件箱部分,用户可以单击主题标题打开一个窗口并阅读他们的邮件 我加入了一个javascript函数,当收件箱消息移动光标时,它会高亮显示这些消息。我已经将突出显示设置为可单击,并且假设它会转到与用户单击主题链接相同的位置,而当它转到窗口read_message.php时,它不会加载消息id,消息也不会显示 以下是有效的主题链接: <?php echo "<strong><a href=\"read_message.php?msg={$inbox['mess

我的网站上有一个收件箱部分,用户可以单击主题标题打开一个窗口并阅读他们的邮件

我加入了一个javascript函数,当收件箱消息移动光标时,它会高亮显示这些消息。我已经将突出显示设置为可单击,并且假设它会转到与用户单击主题链接相同的位置,而当它转到窗口read_message.php时,它不会加载消息id,消息也不会显示

以下是有效的主题链接:

<?php echo "<strong><a href=\"read_message.php?msg={$inbox['message_id']}\">{$inbox['subject']}</a></strong>"; ?>

下面是链接不起作用的javascript:

<script>
     $(function() {
        $('tr').hover(function() {
            $(this).css('background-color', '#eee');
            $(this).contents('td').css({'border': '0px solid red', 'border-left': 'none', 'border-right': 'none'});
            $(this).contents('td:first').css('border-left', '0px solid red');
            $(this).contents('td:last').css('border-right', '0px solid red');
        },
        function() {
            $(this).css('background-color', '#FFFFFF');
            $(this).contents('td').css('border', 'none');
            $('tr').click(function() { 
    document.location = "<?php echo "read_message.php?msg={$inbox[0]}" ?>";
} );
        });
    });
    </script>

$(函数(){
$('tr')。悬停(函数(){
$(this.css('background-color','#eee');
$(this.contents('td').css({'border':'0px纯红','border left':'none','border right':'none');
$(this).contents('td:first').css('border-left','0px实心红色');
$(this).contents('td:last').css('border-right','0px实心红色');
},
函数(){
$(this.css('background-color','#FFFFFF');
$(this).contents('td').css('border','none');
$('tr')。单击(函数(){
document.location=“”;
} );
});
});

希望有人能告诉我哪里出了问题。谢谢。

首先,您应该移动
.click()
函数,使其不在
函数中。hover()
函数中-否则,每次将鼠标移出行时,都会设置单击处理程序,并且在第一次将鼠标移到该行上时,它将无法工作

完成后,您可以执行以下操作:

$("tr").click(function() {
  location.href = $(this).find("a[href*='read_message.php']").attr("href");
});

(对
.find()
语法没有100%的把握,因为我没有真正使用jQuery,但这应该会有帮助)

首先你应该移动
.click()
函数,这样它就不在你的
.hover()
函数中了-否则每次你把鼠标移出行时,点击处理程序都会被设置好,当你第一次滑鼠过来的时候,它就不起作用了

完成后,您可以执行以下操作:

$("tr").click(function() {
  location.href = $(this).find("a[href*='read_message.php']").attr("href");
});

(对于
.find()
语法没有100%的把握,因为我并不真正使用jQuery,但这应该会有所帮助)

javascript函数中带有PHP的行在呈现页面中是什么样子的?javascript函数中带有PHP的行在呈现页面中是什么样子的?答案的第一部分就足够了。我认为重构后的“tr”中没有锚。只需回答第一部分就足够了。我认为重构后的“tr”中没有锚。