以下javascript代码有什么问题

What is wrong with following javascript code

本文关键字:什么 问题 代码 javascript 以下      更新时间:2024-04-04

下面的代码有什么问题?我遇到了把双引号和单引号混用的问题。因此,我为onclick定义了单独的方法。一些看起来语法不正确的

<table style='border-style:none; cursor:pointer;' onclick="myFunc()" >

function myFunc() {
    width1= getWindowDim().width; 
    height1= getWindowDim().height; opt23='resizable=yes,fullscreen=yes,location=no,toolbar=no,directories=no,status=no,menubar=no,scrollbars=yes,fullscreen=yes,width='+width1 +',height='+heigh1;
    window.open('http://ibm.com','popupwin',opt23); 
}

使用jquery获取高度和宽度,它可以在中工作

     $(window).height();   // returns height of browser viewport
 $(document).height(); // returns height of HTML document
 $(window).width();   // returns width of browser viewport
 $(document).width(); // returns width of HTML document

试试这个,onclick缺少双引号

<table style="border-style:none; cursor:pointer;" onclick="myFunc()" >
function myFunc() {
    width1 = getWindowDim().width; 
    height1 = getWindowDim().height;
    opt23 = 'resizable=yes,fullscreen=yes,location=no,toolbar=no,' + 
            'directories=no,status=no,menubar=no,scrollbars=yes,' + 
            'fullscreen=yes,width= ' + width1 + ',height=' + heigh1;
    window.open('http://ibm.com','popupwin',opt23); 
}