我有一个JSP页面,它在触发事件后显示此信息:
这是我打开“窗口”的样式:
$('body').pWin("open", {
x: 260,
y: 47,
height: 450,
width: 881,
title: "Generate URL",
skinMode:'dialog',
iframe:true,
url: "file/url/genurl.jsp",
data: {
nodeID:stringArray
},
offResize:true,
offMove:true,
onTitle:false,
offBottom:true
});
单击“编辑”按钮后,它应该像上面一样打开一个新窗口:
genurl.jsp:
$('body').pWin("open", {
x: 260,
y: 47,
height: 450,
width: 881,
title: "Edit:Advance configuration",
skinMode:'dialog',
iframe:true,
url: "editUrl.jsp",
data: {
filename:x
},
offResize:true,
offMove:true,
onTitle:false,
offBottom:true
});
}
我使用相同的方式打开新窗口。
仅为您的信息,这是pWin.js:
/**
* open settings {
* x
* y
* width
* height
* title
* url
* iframe (optional)
* offTitle (optional)
* offBottom (optional)
* offResize (optional)
* offMove (optional)
* skinMode (optional) default to basic
* onClose (optional)
*
* }
*
*/
$.fn.extend({
pWin: function (option, settings) {
if (option == "open") {
for (var i=0; i<$.pWin_defaults.openParam.length; i++) {
if (!settings[$.pWin_defaults.openParam[i]]) {
alert('pWin.open requires ' + $.pWin_defaults.openParam[i]);
return false;
}
}
var skinMode = 'basic';
if (settings.skinMode) {
skinMode = settings.skinMode;
}
var id = ++$.pWin_defaults.id + $.pWin_defaults.prefix;
var winWidth = settings.width;
var winHeight = settings.height;
var winY = settings.y;
var winX = settings.x;
if (winWidth == 'max') {
winWidth = $(document).width();
if (skinMode == 'dialog') {
winWidth -= 10;
}
winY = 0;
}
if (winHeight == 'max') {
winHeight = $(document).height() - $.pWin_defaults.topHeight;
if (!settings.offBottom) {
winHeight -= $.pWin_defaults.botHeight;
}
if (skinMode == 'dialog') {
winHeight -= 10;
}
winX = 0;
}
var divWindow = $('<div id=\'pWin_'+id+'\' class=\'pWin\'></div>');
divWindow.title = settings.title;
divWindow.bind('click', function() { $(this).pWin_activate() });
if (skinMode == 'dialog') {
divWindow.addClass('pWinDialog');
}
divWindow.css('top', winY);
divWindow.css('left', winX);
if (settings.offBottom) {
divWindow.css('height', winHeight + $.pWin_defaults.topHeight + $.pWin_defaults.botHeight);
} else {
divWindow.css('height', winHeight + $.pWin_defaults.topHeight + $.pWin_defaults.botHeight);
}
divWindow.css('width', winWidth);
divWindow.css('z-index', ++$.pWin_defaults.winZIndex);
/*
var topLeft = $('<div class=\'pWin_tl\'></div>');
topLeft.css('height', $.pWin_defaults.topHeight);
topLeft.css('width', $.pWin_defaults.cornerWidth);
if (skinMode == 'basic') {
topLeft.css('background', 'url(' + $.pWin_defaults.images + $.pWin_defaults.imgTopLeft + ')');
} else if (skinMode == 'dialog') {
topLeft.css('background', 'url(' + $.pWin_defaults.images + $.pWin_defaults.imgTopLeftDialog + ')');
}
*/
var topCenter = $('<div id=\'pWinTitle_'+id+'\' class=\'pWinTitle\'></div>');
var textWidth = 0;
if (skinMode == 'basic') {
topCenter.addClass('pWinTitleBasic');
textWidth = $.pWin_text_width(settings.title, 'pWinTitleBasic', '');
} else if (skinMode == 'dialog') {
topCenter.addClass('pWinTitleDialog');
textWidth = $.pWin_text_width(settings.title, 'pWinTitleDialog', '');
}
divWindow.attr('minWidth', textWidth + 80);
var iePad = 0;
if ($.pWin_defaults.isIE) {
iePad = 6;
}
//topCenter.css('width', winWidth - $.pWin_defaults.cornerWidth * 2 - iePad);
topCenter.css('width', winWidth - iePad);
topCenter.css('height', $.pWin_defaults.topHeight);
if (skinMode == 'dialog') {
topCenter.css('height', $.pWin_defaults.DialogTopHeight);
}
if (skinMode == 'basic') {
//topCenter.css('background', 'url(' + $.pWin_defaults.images + $.pWin_defaults.imgTopCenter + ') repeat-x');
} else if (skinMode == 'dialog') {
//topCenter.css('background', 'url(' + $.pWin_defaults.images + $.pWin_defaults.imgTopCenterDialog + ') repeat-x');
}
if (!settings.offMove) {
topCenter.bind('mousedown', function(e) { $(this).pWin_move_lock(e) });
topCenter.addClass('pWinMove');
}
var topTitleName = $('<div class=\'pWinTitleText\' id=\'pWinTitleName_'+id+'\' >'+settings.title+'</div>');
var topButton = $('<div title=\'Close Window\' class=\'pWinCursor pWinTitleButton\' ></div>');
if (skinMode == 'basic') {
topButton.html('<img class=\'pWinCursor\' src=\'' + $.pWin_defaults.images + $.pWin_defaults.imgCloseButton + '\'/>');
} else if (skinMode == 'dialog') {
topButton.addClass('pWinButtonDialog');
topButton.html('<img class=\'pWinCursor\' src=\'' + $.pWin_defaults.images + $.pWin_defaults.imgCloseButtonDialog + '\'/>');
}
if (skinMode == 'basic') {
topTitleName.addClass('pWinTitleNameBasic');
} else if (skinMode == 'dialog') {
topTitleName.addClass('pWinTitleNameDialog');
}
if (settings.onClose) {
topButton.bind('mousedown', settings.onClose);
}
topButton.bind('mousedown', function() {
$(this).pWin('close', id);
});
topCenter.append(topTitleName);
topCenter.append(topButton);
/*
var topRight = $('<div class=\'pWin_tr\'></div>');
topRight.css('height', $.pWin_defaults.topHeight);
topRight.css('width', $.pWin_defaults.cornerWidth);
if (skinMode == 'basic') {
topRight.css('background', 'url(' + $.pWin_defaults.images + $.pWin_defaults.imgTopRight + ')');
} else if (skinMode == 'dialog') {
topRight.css('background', 'url(' + $.pWin_defaults.images + $.pWin_defaults.imgTopRightDialog + ')');
}
*/
var clear = $('<div class=\'pWin_clear\'></div>');
if (!settings.offTitle) {
//divWindow.append(topLeft);
divWindow.append(topCenter);
//divWindow.append(topRight);
divWindow.append(clear);
}
var winContent = $('<div id=\'pWinContent_'+id+'\' class=\'pWinContent\'></div>');
winContent.css('width', winWidth - 2); // minus 2 for the borders
winContent.css('height', winHeight);
if (settings.corner) {
winContent.css('-moz-border-radius', '5px');
}
if (skinMode == 'basic') {
winContent.addClass('pWinContentBasic');
} else {
winContent.css('height', winHeight + 20);
}
var winFrame = undefined;
if (settings.iframe) {
winFrame = $('<iframe id=\'pWinFrame_'+id+'\' name=\'pWinFrame_'+id+'\' ></iframe>');
/*winFrame.css('width', winWidth - 2);
winFrame.css('height', winHeight);*/
winFrame.css({
"width" : "100%",
"height" : "100%"
});
winFrame.css('border','0');
winFrame.attr('frameBorder','0');
winFrame.attr('frameBorder','0');
winContent.append(winFrame);
}
else {
// put in a loading bar here
}
divWindow.append(winContent);
/*
var botLeft = $('<div class=\'pWin_bl\'></div>')
botLeft.css('width', $.pWin_defaults.cornerWidth);
botLeft.css('height', $.pWin_defaults.botHeight);
if (skinMode == 'basic') {
botLeft.css('background', 'url('+$.pWin_defaults.images+$.pWin_defaults.imgBotLeft+')');
}
*/
var botCenter = $('<div id=\'pWinBotCenter_'+id+'\' class=\'pWinBotCenter\'></div>');
//botCenter.css('width', winWidth - $.pWin_defaults.cornerWidth*2);
botCenter.css('width', winWidth);
botCenter.css('height', $.pWin_defaults.botHeight);
if (skinMode == 'basic') {
botCenter.css('background', 'url('+$.pWin_defaults.images+$.pWin_defaults.imgBotCenter+') repeat-x');
}
if (!settings.offResize) {
var botResize = $('<div title=\'Resize Window\' id=\'pWinResize_'+id+'\' class=\'pWinResize\'></div>');
botResize.css('background', 'url('+$.pWin_defaults.images+$.pWin_defaults.imgResize+')');
botResize.bind('mousedown', function() {
return false;
});
botResize.bind('mousedown', function(e) { $(this).pWin_resize_lock(e) });
botCenter.append(botResize);
}
/*
var botRight = $('<div class=\'pWin_br\'></div>')
botRight.css('width', $.pWin_defaults.cornerWidth);
botRight.css('height', $.pWin_defaults.botHeight);
if (skinMode == 'basic') {
botRight.css('background', 'url('+$.pWin_defaults.images+$.pWin_defaults.imgBotRight+')');
}
*/
var botClear = $('<div class=\'pWin_clear\'></div>');
if (!settings.offBottom) {
//divWindow.append(botLeft);
divWindow.append(botCenter);
//divWindow.append(botRight);
divWindow.append(botClear);
}
$.pWin_defaults.winMap[settings.title] = id;
$(this).append(divWindow);
if (winFrame) {
if(window.frames["pWinFrame_" + id].name != "pWinFrame_" + id) { /* *** IMPORTANT: This is a BUG FIX for Internet Explorer *** */ window.frames["pWinFrame_" + id].name = "pWinFrame_" + id; }
$('#pWinFrame_' + id).pWin_loadFrame(settings.url, settings.data);
} else {
settings.data.id = id;
$.post(settings.url, settings.data, function(data) {
winContent.html(data);
}, 'text');
}
return id;
} else if (option == "close") {
if (document.getElementById('pWin_' + settings)) {
$("#pWin_" + settings).remove();
delete ($.pWin_defaults.winMap[settings]);
} else {
if ($.pWin_defaults.winMap[settings]) {
$('#pWin_' + $.pWin_defaults.winMap[settings]).remove();
delete ($.pWin_defaults.winMap[settings]);
}
}
} else if (option == 'isOpen') {
var titles = $('.pWinTitleText');
for (var i=0; i<titles.length;i++) {
var title = titles[i].html();
if (title == settings) {
return true;
}
}
return false;
}
else {
}
return false;
},
问题是新窗口在同一父窗口下方打开,并显示“ Edit:Advance configuration”,如屏幕截图所示,我希望它替换当前窗口。它似乎出现在当前父窗口的下方,我不知道出了什么问题。
我该怎么做?