【问题标题】:Javascript - String concatenationJavascript - 字符串连接
【发布时间】:2014-03-17 21:12:14
【问题描述】:

我有这个功能:

javascript:

function popup(mylink, windowname, w, h)
{
if (! window.focus)return true;
var href;
if (typeof(mylink) == 'string')
   href=mylink;
else
   href=mylink.href;
window.open(href, windowname, "width=w,height=h,scrollbars=yes,toolbar=no" );
return false;
}

html:

<a href="test.html"  onClick="return popup(this, 'Test', '400', '600')">test</a>

我试图在字符串中插入变量 wh 但没有成功。在 javascript 中执行此操作的正确方法是什么?

【问题讨论】:

    标签: javascript


    【解决方案1】:

    为什么要进行字符串连接!

    "width=" + w + ",height=" + h + ",scrollbars=yes,toolbar=no"
    

    【讨论】:

      【解决方案2】:
      window.open(href, windowname, "width=" + w + ",height=" + h + ",scrollbars=yes,toolbar=no" );
      

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 2014-04-29
        • 2020-01-21
        • 2013-10-13
        • 1970-01-01
        • 2020-12-05
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        相关资源
        最近更新 更多