【问题标题】:onClick image link not workingonClick图像链接不起作用
【发布时间】:2014-02-20 05:14:19
【问题描述】:

我有一个带有 onClick 图像链接的页面。单击图像时,会打开一个弹出窗口。在弹出窗口上,我有另一个 onClick 图像链接,它应该打开另一个弹出窗口,但该链接不起作用。我对两个链接使用相同的代码。为什么第一个链接有效,而第二个链接无效?我使用的代码是:

<a href="#" onclick=
"window.open(’target URL','_blank','toolbar=0, location=0, directories=0, status=0, scrollbars=1, resizable=0, copyhistory=0, menuBar=0, width=700, height=2700');return(false)">
<img height="110" src="%E2%80%9Cimage" width="180"></a>

【问题讨论】:

  • 为什么'在window.open('应该有'
  • 我使用的代码是: 代码由 Daniel Lisik 编辑
  • 您发布了完全相同的错误。在 windows.open 中重新键入 first '

标签: javascript html hyperlink onclick


【解决方案1】:

你有一个 而不是'。变化:

window.open(’ta

到:

window.open('ta

【讨论】:

    【解决方案2】:

    您应该消除属性之间的空格,例如resizable=0, copyhistory=0 成为resizable=0,copyhistory=0。也放在一行中。

    这里是fiddle

    和代码:

    <a  href="#" onclick = window.open("target_url","_blank","toolbar=0,location=0,directories=0,status=0,scrollbars=1,resizable=0,copyhistory=0,menuBar=0,width=700,height=2700");return(false)><img height="110" src="%E2%80%9Cimage" width="180"></a>
    

    【讨论】:

    • 嗯.. 从未听说过空间会造成损坏。另外,onclick 属性不应该有括号内的值吗?
    • 你可以看到她在这个小提琴jsfiddle.net/2GPzs 完全相同的代码,但现在有空格会导致问题 - 窗口没有打开
    • 您的代码也相同,因为您删除了 onclick 属性值周围的双引号。
    • 不同之处在于您的代码使用单括号和我的双括号。
    猜你喜欢
    • 2011-07-08
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2023-03-22
    • 2019-05-07
    相关资源
    最近更新 更多