繁体   English   中英

同一网页上的两个jQuery对话框存在问题

[英]Two jQuery dialogs on the same webpage have an issue

我有一个用户控件,它有一个jQuery对话框。 jQuery对话框有iframe用于打开网页test1.aspx。 另外我有一个网页有jQuery对话框,其中对话框还有用于打开网页的iframe,'test2.aspx'。 如果用户控件不在同一网页中,则这两个对话框可以正常工作。 一旦两个对话框在同一页面上。 用户控件上的jQuery对话框一直显示test2.aspx,而不是test1.aspx。 有时对话位置在靠近用户控件的链接下。 该对话框旨在打开顶部。

用户控件上有代码段:

 <a title="Edit" onclick="openBoxTest('test1.aspx?id=659333','test',650,310, 'dialog1'); return false">Edit</a>
   <div id="dialog1">  <iframe id="myIframe" src="" ></iframe></div>

网页上有代码段:

  <span onclick="openBoxTest('/test2.aspx?ID=652','test2',650,310, 'dialog2');  return false" >test2</span>"
 <div id="dialog2">  <iframe id="myIframe" src="" ></iframe></div>

有打开对话框的脚本:

function openBoxTest(url, name, width, height,  divID) {    
var box = $('#' + divID);   
  box.dialog({
    autoOpen: false,    
    max_height: 'auto',        
    height: 'auto',      
    width: 'auto',
    title: name,
    modal: true,

    position: {
        my: 'top',
        at: 'top',
        of: window,
        collision: "flip"
    },
    create: function (event, ui) {
        $(event.target).parent().css('position', 'fixed');
    },


    open: function (ev, ui) {          
        $('#myIframe').css('height', height+60);
        $('#myIframe').css('width', width);
        $('#myIframe').attr('src', url);

    },
});

  box.dialog('open');
return false;
}

这有点难以理解你所描述的内容,但我的第一个猜测是你在dialog1和dialog2中的两个iframe都有ID = myIframe。 如果它们在同一页面上,这可能是您的问题。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM