一些易忘js或技巧

//一:刷新父窗口中的iframe 方法:

//语句1.

window.parent.frames[1].location.reload();

//语句2.

window.parent.frames.bottom.location.reload();

// 语句3.

window.parent.frames["bottom"].location.reload();

//语句4.

window.parent.frames.item(1).location.reload();

//语句5.

window.parent.frames.item('bottom').location.reload();

//语句6.

window.parent.bottom.location.reload();

//语句7.

window.parent['bottom'].location.reload(); top.html

//二:清空值
function PageClear() {
    var list = document.getElementsByTagName("input");
    var item = document.getElementsByTagName("select");
    txtClear(list);
    ddlClear(item);
}
//清空文本框
function txtClear(list) {
    if (list != null && list != undefined && list != NaN && list.length > 0) {
        for (var n = 0; n < list.length; n++) {
            if (list[n] && list[n].type == "text" && list[n].value != "")
                list[n].value = "";
        }
    }
}
//清空下拉框
function ddlClear(item) {
    if (item != null && item != undefined && item != NaN && item.length > 0) {
        for (var n = 0; n < item.length; n++) {
            if (item[n])
                item[n].selectedIndex = 0;
        }
    }
}
//三:二级绑定
function TP_lTypeBind(ddl_TP_lType, ddl_TP_sType) {
    var fvalue = ddl_TP_lType.value;
    if (fvalue && fvalue != "") {
        var dt = Report_CopyRightAdd.ddl_TP_sTypeBind(fvalue)
        ddlLink(ddl_TP_sType, dt, "sName", "id")
    }
    else {
        var ddlItem = document.getElementById(ddl_TP_sType);
        ddlItem.length = 0;
        var op = document.createElement("option");
        op.setAttribute("value", "");
        var txt = document.createTextNode("==请选择==");
        op.appendChild(txt);
        ddlItem.appendChild(op);
    }
}
// 二级绑定
function ddlLink(ddlItem, dt, text, value) {
    var ddlItem = document.getElementById(ddlItem);
    ddlItem.length = 0;
    if (dt != null) {
        if (dt.value.Rows.length > 0) {
            var op = document.createElement("option");
            op.setAttribute("value", "");
            var txt = document.createTextNode("==请选择==");
            op.appendChild(txt);
            ddlItem.appendChild(op);
            for (var i = 0; i < dt.value.Rows.length; i++) {
                op = document.createElement("option");
                op.setAttribute("value", dt.value.Rows[i][value]);
                txt = document.createTextNode(dt.value.Rows[i][text]);
                op.appendChild(txt);
                ddlItem.appendChild(op);
            }
        }
        else {
            var op = document.createElement("option");
            op.setAttribute("value", "");
            var txt = document.createTextNode("==请选择==");
            op.appendChild(txt);
            ddlItem.appendChild(op);
        }

    }
}

你可能感兴趣的:(js)