今天我試圖從StacOverflow中使用img屬性代碼,但未成功。無法在HTML中正確使用<img src=""onclick='window.open('anotherpage.html','_blank");' />屬性
<img src="..." alt="..." onclick="window.open('anotherpage.html', '_blank');" />
從Here!
image.php
<?php
$pic = array('1.jpg','2.jpg','3.jpg','4.jpg','5.jpg');
shuffle($pic);
?>
original.index.php它的工作原理酷
<html>
<head>
<title>Random Images</title>
</head>
<body>
<ul>
<?php
include("img/image.php");
for($i = 0; $i < 3; $i++)
echo "<li style=\"display: inline;\">
<img src=\"$pic[$i]\" width=\"250\" height=\"250\">
</li>";
?>
</ul>
</body>
</html>
in.my.case.index.php
<html>
<head>
<title>Random Images</title>
</head>
<body>
<ul>
<?php
include("img/image.php");
for($i = 0; $i < 3; $i++)
echo "<li style=\"display: inline;\">
<img src=\"$pic[$i]\" width=\"150\" height=\"130\" alt=\"Go to back\" onclick=\"window.open(\"anotherpage.php\", \"_blank\");\" />
</li>";
?>
</ul>
</body>
</html>
不審判嚴格
坦克男人,工作很酷 – YobrHabr