Php 如何通过Window.open在弹出窗口中显示图像
我正在尝试使用以下javascript在弹出窗口中显示图像Php 如何通过Window.open在弹出窗口中显示图像,php,html,window.open,Php,Html,Window.open,我正在尝试使用以下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') } 在Html代码中
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')
}
在Html代码中,我使用php目录迭代器查找jpeg图像并将其传递给javascript。但是弹出窗口不会打开
echo '<td width="150"><a href="JavaScript:newPopup('.$file_name.');">ScreenShot</a></td>';
echo';
我在这里做错了什么
<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>
函数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,Directory=no,status=yes')
}
我认为您在$filename
echo '<td width="150"><a href="javascript:void(0);" onclick="newPopup(\''.$file_name.'\');">ScreenShot</a></td>';
echo';
图像不是来自url,而是存储在php变量中。此代码不适用于这种情况。您可以添加php变量来代替url。它会起作用的。我只是给你看一个例子。我用下面的语句尝试了你的代码,echo“当你给出包括http在内的整个路径时,图像会显示出来,而不是我写的完整路径的目录路径。在评论中,它们是不正确的