Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/250.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
Javascript 如何在字符串echo';中使用window.open;来自PHP的d?_Javascript_Php_Jquery_Html - Fatal编程技术网

Javascript 如何在字符串echo';中使用window.open;来自PHP的d?

Javascript 如何在字符串echo';中使用window.open;来自PHP的d?,javascript,php,jquery,html,Javascript,Php,Jquery,Html,通过$\u POST请求,我查询数据库并以字符串形式返回信息,如下所示: $output .='<div class="searchdiv"> <b>'.$tit.' </b>- '.$art.' <br> <a href="#" onclick="window.open('.$prev.', "_blank", "width=600,height=350");" >preview tutorial</a> - <a

通过$\u POST请求,我查询数据库并以字符串形式返回信息,如下所示:

$output .='<div class="searchdiv"> <b>'.$tit.' </b>- '.$art.' <br> <a href="#" onclick="window.open('.$prev.', "_blank", "width=600,height=350");" >preview tutorial</a> - <a href="'.$wat.'" target="blank">watch full tutorial</a></div>'; 
$output.='.$tit.-'.$art.
-';
我的问题是“window.open”语句。它在普通html文档中作为内联JS工作如下:

$output .='<div class="searchdiv"> <b>'.$tit.' </b>- '.$art.' <br> <a href="#" onclick="window.open('.$prev.', "_blank", "width=600,height=350");" >preview tutorial</a> - <a href="'.$wat.'" target="blank">watch full tutorial</a></div>'; 
$output.='.$tit.-'.$art.
-';

但是我认为PHP字符串中的问题是单引号和双引号。我做错了什么?

URL周围需要引号

$output .= '... <a href="#" onclick="window.open("' . $prev . '", "_blank", ...
// ---------------------------------------- here ^ -- and here ^

$output.=' 您需要在URL周围加引号

$output .= '... <a href="#" onclick="window.open("' . $prev . '", "_blank", ...
// ---------------------------------------- here ^ -- and here ^

$output.=' 看来你把这里的引语弄错了

$output .='<div class="searchdiv"> <b>'.$tit.' </b>- '.$art.' <br> <a href="#" onclick="window.open('.$prev.', "_blank", "width=600,height=350");" >preview tutorial</a> - <a href="'.$wat.'" target="blank">watch full tutorial</a></div>';
而且,如果
$prev
没有引用JS中的变量(如果它将以字符串结束),那么也需要在其周围加上引号

\''.$prev.'\'

看来你把这里的引语弄错了

$output .='<div class="searchdiv"> <b>'.$tit.' </b>- '.$art.' <br> <a href="#" onclick="window.open('.$prev.', "_blank", "width=600,height=350");" >preview tutorial</a> - <a href="'.$wat.'" target="blank">watch full tutorial</a></div>';
而且,如果
$prev
没有引用JS中的变量(如果它将以字符串结束),那么也需要在其周围加上引号

\''.$prev.'\'

检查浏览器中生成的html并确认其格式是否正确。
onclick=“window.open”(“$prev.”),“\u blank”,“width=600,height=350”);“
@DigitalDennis完成了我下面的帮助?检查浏览器中生成的html并确认html格式是否正确。
onclick=“window.open”(“$prev.”,“\u blank”宽度=600,高度=350“;”
@DigitalDennis我下面的答案有帮助吗?