简体   繁体   English

使用图片onclick执行JavaScript函数

[英]Execute a JavaScript function using image onclick

I'm attempting to execute the following JavaScript function(pop up a new window) when clicking on an image but doesn't work. 我试图在单击图像时执行以下JavaScript函数(弹出一个新窗口),但不起作用。 can you please help me correct the code? 您能帮我更正密码吗?

    <script language="javascript">
    var win = null;
    function NewWindow(wizpage, wizname, w, h, scroll){
    LeftPosition = (screen.width) ? (screen.width-w)/2 : 0;
    TopPosition = (screen.height) ? (screen.height-h)/2 : 0;
     settings = 'height=' + h + ',width=' + w + ',top= 100,' + TopPosition + 
   ',left=' + LeftPosition + ',scrollbars=' + scroll + ',resizable'
    win = window.open(wizpage, wizname, settings)
    }
    </script>
    <FORM>
    <INPUT TYPE="Image" SRC="https://communities-
    qa.connect.te.com/sites/GP/Indirect/PublishingImages/clickhere2.jpg" 
    Alt="Contact Us" onClick="
    NewWindow('www.google.com','name','590','390','yes');return false"></FORM>

thanks a lot 非常感谢

Blocked opening ' https://www.google.com/ ' in a new window because the request was made in a sandboxed frame whose 'allow-popups' permission is not set. 阻止在新窗口中打开“ https://www.google.com/ ”,因为该请求是在未设置“允许弹出窗口”权限的沙盒框架中发出的。

  var win = null; function NewWindow(wizpage, wizname, w, h, scroll){ LeftPosition = (screen.width) ? (screen.width-w)/2 : 0; TopPosition = (screen.height) ? (screen.height-h)/2 : 0; settings = 'height=' + h + ',width=' + w + ',top= 100,' + TopPosition + ',left=' + LeftPosition + ',scrollbars=' + scroll + ',resizable' win = window.open(wizpage, wizname, settings) } 
  <FORM> <INPUT TYPE="Image" SRC="https://communities- qa.connect.te.com/sites/GP/Indirect/PublishingImages/clickhere2.jpg" Alt="Contact Us" onClick=" NewWindow('https://www.google.com','name','590','390','yes');return false"></FORM> 

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM