简体   繁体   English

如何通过Window.open在弹出窗口中显示图像

[英]How to display a Image in Pop up Window through Window.open

I am trying to display a image in a window pop up using the following javascript 我正在尝试使用以下JavaScript在弹出的窗口中显示图像

function newPopup(url) {
    popupWindow = window.open(
        url,'popUpWindow','height=700,width=800,left=10,top=10,resizable=yes,scrollbars=no,toolbar=no,menubar=no,location=no,directories=no,status=yes')
}

In the Html code I am using php directory Iterator to find jpeg image and pass it to the javascript. 在HTML代码中,我使用php目录迭代器查找jpeg图像并将其传递给javascript。 But the pop up window does not open. 但是弹出窗口没有打开。

echo '<td width="150"><a href="JavaScript:newPopup('.$file_name.');">ScreenShot</a></td>';

What am I doing wrong here 我在这里做错了什么

I think you are missing extra single quots around the $filename 我认为您在$filename周围缺少多余的单引号

echo '<td width="150"><a href="javascript:void(0);" onclick="newPopup(\''.$file_name.'\');">ScreenShot</a></td>';

http://jsbin.com/aqurem/1/edit http://jsbin.com/aqurem/1/edit

<script>
function newPopup(url) {
    popupWindow = window.open(
        url,'popUpWindow','height=700,width=800,left=10,top=10,resizable=yes,scrollbars=no,toolbar=no,menubar=no,location=no,directories=no,status=yes')
}
</script>
<a href="javascript:void(0);" onClick="newPopup('https://www.cs.washington.edu/education/courses/cse455/12au/projects/project1/students/chantalm/artifact/images/flowers.jpg');">ScreenShot</a>

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM