我现在已经尝试了几个小时试图让这个工作。但是,代码工作正常,但第二个按钮不会显示在我的网站上。你能帮忙吗?
echo "<td><input class=button_normal type=button value=Google Renter onclick=window.window.open(href='https://www.google.co.uk/')";
echo "<input class=button_normal type=button value=Yahoo onclick=window.window.open(href='https://www.yahoo.co.uk')</td>";
&#13;
答案 0 :(得分:1)
您还没有为onclick,value和class添加引用。您也忘记关闭输入标记。
echo "<td><input class='button_normal' type='button' value='Google Renter' onclick='window.window.open.href=\'https://www.google.co.uk/\''/>";
echo "<input class='button_normal' type='button' value='Yahoo' onclick='window.location.href=\'https://www.yahoo.co.uk\''/></td>";
我的建议是:
<script>
function goToYahoo() {
window.open('https://www.yahoo.co.uk');
}
function goToGoogle() {
window.open('https://www.google.co.uk');
}
</script>
<?php
echo "<td><input class='button_normal' type='button' value='Google Renter' onclick='goToGoogle()'/>";
echo "<input class='button_normal' type='button' value='Yahoo' onclick='goToYahoo()'/></td>";
?>
答案 1 :(得分:0)
window.location
属性不是方法:
window.location(href='https://www.yahoo.co.uk')
应该是:
window.location.href='https://www.yahoo.co.uk'
答案 2 :(得分:0)
基本上在您的代码中,您缺少输入标记关闭&#34; /&gt;&#34;
echo <<<"FOOBAR"
<td>
<input class="button_normal" type="button" value="Google Renter" onclick="window.open('https://www.google.co.uk/')"/>;
<input class="button_normal" type="button" value="Yahoo" onclick="window.open('https://www.yahoo.co.uk')"/>
</td>
FOOBAR;