[英]Closing and opening two model pop-ups subsequently on a Button's Click event using JQuery
我正在使用 JQuery 打開和關閉 model 彈出窗口。
//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');
});
}
當我們將關閉 function 與彈出窗口 window 的“取消”按鈕一起使用時,它工作正常。
但我想關閉一個打開的彈出窗口 window 並隨后使用相同的鏈接按鈕打開一個新的彈出窗口,為此我在 aspx.cs 頁面的 Page_load 嘗試如下:
lnkButton.Attribues.Add("onClick","UserSignUpClose();");
lnkButton.Attribues["onClick"]+="UserSignupModalpopupFromSubDomain(location.href,document.title);";
但它不起作用當我嘗試獲取和使用它的 id 時,我無法獲取它的屬性,如 id 和 type 和 innerHTML。
事先感謝。
您正在分配iframe-signup
、 mb_Error_Popup
和mb_Title_Popup
作為元素的 ID,但您使用的是$('iframe-signup').src = srcFile;
選擇元素 jQuery 用於選擇具有 ids 的元素的語法如下
$('#iframe-signup').src = srcFile; // the # sign
對所有此類選擇執行相同操作
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.