常用的js代码

下载文件

View Code
parent.location.href

弹出全屏窗口

View Code
function openWin(formUrl) {

    var hWnd

    hWnd = window.open(formUrl, '', 'height=' + new String(screen.availHeight - 28) + ',top=0,left=0,width=' + new String(screen.availWidth - 10) + ',location=no,menubar=no,resizable=yes,toolbar=no');

    return hWnd;

}

去掉字符串的头空格(左空格)

View Code
function LTrim(str) {

    var i;

    for (i = 0; i < str.length; i++) {

        if (str.charAt(i) != " ") break;

    }

    str = str.substring(i, str.length);

    return str;

}

去掉字符串的尾空格(右空格)

View Code
function RTrim(str) {

    var i;

    for (i = str.length - 1; i >= 0; i--) {

        if (str.charAt(i) != " ") break;

    }

    str = str.substring(0, i + 1);

    return str;

}

去掉字符串的头尾空格(左右空格)

View Code

你可能感兴趣的:(js)