关闭和打开两个模型弹出窗口随后在按钮's使用JQuery的Click事件

Closing and opening two model pop-ups subsequently on a Button's Click event using JQuery

本文关键字:按钮 Click 事件 JQuery 使用 窗口 模型 两个      更新时间:2023-09-26

我正在使用JQuery打开和关闭一个模型弹出窗口。

//Function to open pop-up
 function UserSignupModalpopupFromSubDomain(guid,title)
{
    var srcFile = "../ModelPopup/SignUpPopup.aspx"; 
 if (guid) srcFile += '?location=' + guid+'&title=' + title; /* sample code to append a unique user ID to page called */ 
    var cFrame = new Element('iframe').setProperties({id:"iframe-signup", name:"iframe-signup", height:'420px', width:'584px', frameborder:"0", scrolling:"no"}).injectInside(document.body);
 $('iframe-signup').src = srcFile;
 customModalBox.htmlBox('iframe-signup', '', 'Sign up'); 
 $('mb_contents_Popup').addClass('yt-Panel-Primary_Popup');
 new Element('div').setHTML(' ').setProperty('id','mb_Error_Popup').injectTop($('mb_center_Popup'));
 new Element('h2').setHTML('Sign UP').setProperty('id','mb_Title_Popup').injectTop($('mb_contents_Popup'));
//    $('mb_center').setStyle('z-index','2005');
//    $('mb_overlay').setStyle('z-index','2004');

      $('mb_center_Popup').setStyle('z-index','2005');
   $('mb_overlay_Popup').setStyle('z-index','2004');

}

// pop-up close function
function UserSignUpClose() {
 $('mb_close_link').addEvent('click', function() {
  //if($('yt-UserProfileContent1')) $('yt-UserProfileContent1').remove();
  if($('iframe-signup')) $('iframe-signup').remove();
  if($('mb_Title_Popup')) $('mb_Title').remove();
  if($('mb_contents_Popup')) $('mb_contents_Popup').removeClass('yt-Panel-Primary_Popup');
  if($('mb_Error_Popup')) $('mb_Error_Popup').remove();
  $('mb_overlay_Popup').setStyle('z-index','1600');
 });
}

当我们与弹出窗口的"取消"按钮一起使用时,关闭功能运行良好。

但我想关闭一个打开的弹出窗口,然后使用相同的链接按钮打开一个新的弹出窗口。为此,我在aspx.cs页面的Page_load上尝试了如下操作:

lnkButton.Attribues.Add("onClick","UserSignUpClose();");
lnkButton.Attribues["onClick"]+="UserSignupModalpopupFromSubDomain(location.href,document.title);";

但它不起作用当我尝试获取和使用它的id时,我无法获取它的属性,如id和type以及innerHTML。

事先谢谢。

您将iframe-signupmb_Error_Popupmb_Title_Popup指定为元素的id,但使用$('iframe-signup').src = srcFile;来提取元素用于选择带有id的元素的jQuery语法如下

$('#iframe-signup').src = srcFile;  // the # sign

对所有此类选择执行相同操作