我尝试将此行添加到我的 PHP 代码中:
<a href="#" onClick="window.open('yourpage.htm','pagename','resizable,height=640,width=360'); return false;">New Page</a>
PHP:
$html_table .= "<td> <a href="#" onClick="window.open('mypage.htm','pagename','resizable,height=640,width=360'); return false;"><button type='button' class='btn btn-success'>test</button></a></td>";
但它不适用于 "
里面。
更改我的代码的最佳方法是什么?
谢谢
最佳答案
您需要转义引号:
<?php
$html_table .= "<td> <a href=\"#\" onClick=\"window.open('mypage.htm','pagename','resizable,height=640,width=360'); return false;\"><button type='button' class='btn btn-success'>test</button></a></td>";
关于javascript - 在php中的表中添加onclick事件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/53541317/