javascript - 在新窗口中打开图像的脚本不起作用
问题描述
我正在使用此代码在新窗口中打开图像,但我无法让它工作。怎么了?
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>
";
解决方案
[测试]
<?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>";
?>
推荐阅读
- java - 假设@Transient 使JPA 提供程序始终保持带注释的字段不变,是否安全?
- reveal.js - Reveal.js 在图像上显示水平线
- java - 我不知道为什么我的 springboot 应用程序无法查询数据库
- reactjs - 无法在 Reactjs 中暂停音频
- jmeter - 如何从 Jmeter 中的子采样器请求中提取值
- python - 由于图像增强或噪声而欠拟合?
- r - 仅突出显示标记的值
- php - 模型 [App\Product] 没有查询结果,同时从表 laravel 7 中获取所有数据
- docker - K8S - Docker - ARM unbutu 64 位 - qemu:未捕获的目标信号 11(分段错误) - 核心转储
- python-3.x - 什么可能导致我的代码给出错误的答案?