javascript对对话没有影响

时间:2015-09-17 01:21:26

标签: javascript jquery

我有一个运行一些javascript的aspx文件。当我使用window.showModalDialog打开它时它工作正常。但它在Chrome上不起作用,所以我使用jquery在对话框中打开它。页面加载到对话框中,但javascript函数无效。有人会告诉我如何解决这个问题吗?

有我的javascript:

function checkAll(rptrName, linkButtonId) {
    var select;
    var iNumElems = document.forms[0].elements.length;
    var link = document.getElementById(linkButtonId)

    if (link.innerHTML.indexOf('Select') == 0) {
       select = true;
       link.innerHTML = "Clear All"
    } else {
       select = false;
       link.innerHTML = "Select All"
    }

    for (var i = 0; i < iNumElems; i++) {
        var oElem = document.forms[0].elements[i];
        if ("checkbox" == oElem.type) {
            if (oElem.name.indexOf(rptrName) == 0) {
                oElem.checked = select
            }
        }
    }
}

我通过对话框打开了它的功能

function openDialog(url) {

$("#dialog-box").load(url).dialog({
    id:'location',
    autoOpen: false,
    resizable: true,
    height: 600,
    width: 600,
    modal: true
});

$('#dialog-box').dialog('open');
     return false;
}

父页面上有HTML代码:

<div id="dialog-box" title=" "></div>

<td width="43%" align="right">
    <asp:button 
         id="btnSelect" 
         runat="server" 
         causesvalidation="False" text="Select Locations"
         OnClientClick="javascript:return openDialog('popLocation.aspx');" />
</td>

有调用checkAll函数的代码

Dim pnlRegion As New Panel
            pnlRegion.CssClass = "gridRegion"

            Dim chklRegion As New CheckBoxList
            chklRegion.BorderWidth = Unit.Point(1)
            chklRegion.CellPadding = 2
            chklRegion.RepeatColumns = 3
            chklRegion.RepeatDirection = RepeatDirection.Horizontal
            chklRegion.ID = "chkl" & objR.Value

            myObject.ui.webForms.objBind(chklRegion, objRegionLocations, "Name", "LocationId")

            checkOff(chklRegion)

            ' add select all link
            Dim hypSelectAll As New HyperLink
            hypSelectAll.ID = "hyp" & objR.Value
            hypSelectAll.NavigateUrl = "javascript://"
            hypSelectAll.Text = "Select All"
            hypSelectAll.Attributes.Add("onclick", "checkAll('" & chklRegion.ClientID & "','" & hypSelectAll.ClientID & "');return false;")

            ' add title, select all, then checkboxlis
            pnlRegion.Controls.Add(lblRegion)
            pnlRegion.Controls.Add(hypSelectAll)
            pnlRegion.Controls.Add(chklRegion)

            ' add panel to placeholder
            plcRegions.Controls.Add(pnlRegion)

0 个答案:

没有答案