流程是:php页面调用ajax函数,该函数在不刷新页面的情况下在表中显示用户列表。在这个表中,我放了一个删除和编辑链接。我没有删除链接的问题,但我被困在编辑链接。
我要做的是,当用户点击编辑链接时,会出现一个弹出窗口,在那里,他们可以更新用户的详细信息,但看起来我的弹出窗口没有出现。
javascript函数是:
<script type="text/javascript">
function newWindow(url) {
var x,y;
x = screen.width-35;
y = screen.height-30;
var win = window.open(url,'glossaryWindow','toolbar=no,directories=no,width=500,height=500'+
'screenX=0,screenY=0,top=0,left=0,location=no,status=no,scrollbars=no,resize=yes,menubar=no');
}
我将该功能放在页面顶部。
这是在html标签中调用java函数的php代码
echo "<td>" . '<a href="javascript: newWindow("/test/HTMLPages/popup_update_user.html")">edit</a>' . "</td>";
有可能??
我检查了它的网址是错误的,但这不是问题。弹出窗口根本没有出现。我需要就此事提出建议。
更新:
这是在php中调用标记中的javascript的正确代码:
<?php
echo "<td>" . "<a href=\"#\" onclick=\"newWindow('popup_update_user.html')\">edit</a>". "</td>"; ?>
:d
答案 0 :(得分:1)
问题是在echo中你在调用javascript函数之前打开和关闭语句。
不要在“href”中调用该函数,从“onclick”调用它。
试试这个:
echo "<td> <a href=\"#\" onclick=\"newWindow('/test/HTMLPages/popup_update_user.html')\">edit</a></td>";
修改强> 工作实例
<!DOCTYPE html>
<html>
<head>
<script type="text/javascript">
function newWindow(url) {
var x,y;
x = screen.width-35;
y = screen.height-30;
var win = window.open(url,'glossaryWindow','toolbar=no,directories=no,width=500,height=500'+
'screenX=0,screenY=0,top=0,left=0,location=no,status=no,scrollbars=no,resize=yes,menubar=no');
}
</script>
</head>
<body>
<table>
<tr>
<?php
echo "<td> <a href=\"#\" onclick=\"newWindow('/test/HTMLPages/popup_update_user.html')\">edit</a></td>";
?>
</tr>
</table>
</body>
</html>