我在点击图片时尝试执行以下JavaScript功能(弹出一个新窗口)但不起作用。你能帮我纠正一下代码吗?
<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>
非常感谢
答案 0 :(得分:-1)
在新窗口中阻止打开“https://www.google.com/”,因为请求是在沙盒框架中进行的,其中“allow-popups”权限未设置。
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>