[英]javascript new popup page in php
I'm new in web programming and I have some problem. 我是Web编程的新手,遇到了一些问题。 I want to open a new popup php page from a link clicked but is not work..
我想从单击的链接中打开一个新的弹出php页面,但不起作用。
from this link
从这个连结
echo '<td><a href="#" onClick = "open("../common/sqlDetail_Inform_Reservation.php?id='.$row['Reservation_ID'].'");">OPEN</a></td>';
Script function
脚本功能
function open(url) {
var popup = window.open(url, "_blank", "width=200, height=200") ;
popup.location = url;
}
Best regard : D 最好的问候:D
You have a quotes issue. 您有报价问题。 You need to escape your double quotes that inside a double quoted string:
您需要对双引号字符串中的双引号进行转义:
echo '<td><a href="#" onClick = "open(\"../common/sqlDetail_Inform_Reservation.php?id='.$row['Reservation_ID'].'\");">OPEN</a></td>';
您与引号有冲突,请尝试以下操作:
echo '<td><a href="#" onClick = "open(\'../common/sqlDetail_Inform_Reservation.php?id='.$row['Reservation_ID'].'\');">OPEN</a></td>';
This is a elegant solution to avoid to many click handlers,it uses the new attribute data-SOMETHING to store your id.if you want more compatibility you can also use the rel attribute or title or whatever to store the id. 这是一种避免许多单击处理程序的好方法,它使用新的属性data-SOMETHING存储您的ID。如果您希望获得更大的兼容性,还可以使用rel属性或标题或任何其他方式来存储ID。 less code,faster javascript,easy to edit later.
更少的代码,更快的javascript,以后易于编辑。
<table>
<?php
while($row blabla ){
echo "<tr>
<td>".$row['bla1']."</td>
<td data-id=\"".$row['Reservation_ID']."\">open</td>
</tr>";
}
?>
</table>
<script>
function open(e){
if(e.target.dataset['id']){
window.open('blabla/Reservation.php?id='+e.target.dataset['id']);
}
}
document.getElementsByTagName('table')[0].addEventListener('click',open,false)
</script>
if you don't understand something just ask 如果你不明白什么,那就问
example in javascript... javascript中的示例...
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.