首页 > 解决方案 > 在新窗口中打开图像的脚本不起作用

问题描述

我正在使用此代码在新窗口中打开图像,但我无法让它工作。怎么了?

echo "
<td align='center'>
<a href='images/spasergjengen/" . $row['Grad'] . "'  target='_blank'>
  <img src='images/spasergjengen/" . $row['Grad'] . "' width='125' height='150' 
  title='Spasergjengen' alt='Spasergjengen' />
</a>
<br>
<button onclick='myFunction" . $row['MedlemId'] . "'()'>Se Bilde</button>
<script>
   function myFunction" . $row['MedlemId'] . "'() {     
   window.open('images/spasergjengen/" . $row['Grad'] . "', '_blank',
  'toolbar=yes,scrollbars=yes,resizable=yes
  ,top=200,left=300,width=750,height=565'); } 
</script>
</td>
";

标签: javascriptphp

解决方案


[测试]

<?php  echo "<td align='center'><a href='images/spasergjengen/" . $row['Grad'] . "'  target='_blank'><img src='images/spasergjengen/" . $row['Grad'] . "' width='125' height='150' title='Spasergjengen' alt='Spasergjengen' /></a><br><button onclick='myFunction" . $row['MedlemId'] . "()'>Se Bilde</button>
<script> function myFunction" . $row['MedlemId'] . "() {     window.open('images/spasergjengen/" . $row['Grad'] . ",_blank', 'toolbar=yes,scrollbars=yes,resizable=yes,top=200,left=300,width=750,height=565'); } </script></td>";
?>

推荐阅读