简体   繁体   中英

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. 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.

  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> 

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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