javascript - 如何使用 JavaScript 将 child.jsp 转换为模态或覆盖?
问题描述
所以在这里我想调用一个 child.jsp 作为使用 JavaScript 的模型。以前我showmodaldialog and window.open()
使用 JavaScript 访问子 jsp。它可以工作,但它正在另一个窗口中打开。我想要模态或覆盖视图中的子 jsp。请帮我解决这个问题。提前致谢。
调用函数时showModDilog()
,子 jsp 应处于模式视图或具有更新值的覆盖视图中。
另一方面,我也可以使用这个(<%@include file="child.jsp" %>
) 在正文中包含。但是我传递的值没有在 child.jsp 中更新。
*如果您需要有关此的更多信息,请随时发表评论。我真的很感谢你的帮助。
//function to call child.jsp from Parent.jsp
function showModDilog(retVal,curVal,curRow,varPreVal)
{
var varRetVal = retVal;
var varCurrentValue = curVal;
var varCurrentRow = curRow;
var varPreValue = varPreVal;
qsUrl ="../FOLDER/ContentShowModalDialog.do?title="+"ORDER NO - "+varRetVal+" ALREADY EXISTS &varCurrentValue="+varCurrentValue+"&varCurrentRow="+varCurrentRow+"&varPreValue="+varPreValue;
if(navigator.appName =='Microsoft Internet Explorer')
{
event.keyCode=0;
}
else
{
event.which=0;
}
event.returnValue=0;
if(getBrowser()=='IE')
{
var qsheight ='200';
var args = new Object;
args.window = window;
returnval = showModalDialog(qsUrl, args);
}
else
{
var args = new Object;
args.window = window.opener;
returnval = window.open(qsUrl, args);
}
}
.css 在子 jsp 中使用
.windowModal {
width: 400px;
position: relative;
margin: 10% auto;
padding: 5px 20px 13px 20px;
border-radius: 10px;
background: #fff;
background: -moz-linear-gradient(#fff, #999);
background: -webkit-linear-gradient(#fff, #999);
background: -o-linear-gradient(#fff, #999);
}
.windowModal:target {
opacity:1;
pointer-events: auto;
}
.close {
background: #606061;
color: #FFFFFF;
line-height: 25px;
position: absolute;
right: 5px;
text-align: center;
top: 4px;
width: 24px;
text-decoration: none;
font-weight: bold;
-webkit-border-radius: 12px;
-moz-border-radius: 12px;
border-radius: 12px;
-moz-box-shadow: 1px 1px 3px #000;
-webkit-box-shadow: 1px 1px 3px #000;
box-shadow: 1px 1px 3px #000;
}
.close:hover { background: #00d9ff; }
在子 jsp 中使用的 HTML
<body class="windowModal" bgcolor="#FFCC99">
<div class=" close" style="width: 100%;overflow: auto;height: 100%;background-color: #F0E68C;">
<div style="margin-top: 1%;">
<input type="button" class="close" name="Close" value="X" style="width:8%" onclick="winClose();" >
<label class="labelbold" style="font-weight: bold; float:left;">NAME - </label>
</div>
</div>
</body>
解决方案
假设您的 css 和 html 用于叠加层的样式,您可以发出 ajax 请求来获取页面数据,然后将其放入父页面中。
使用纯 JavaScript,您可以加载子页面,然后将响应的内容放入父 jsp 的容器中:
var xhttp = new XMLHttpRequest();
xhttp.onreadystatechange = function() {
if (this.readyState == 4 && this.status == 200) {
document.getElementById("idOfContainerInsideParent").innerHTML = this.responseText;
}
};
xhttp.open("GET", qsUrl, true);
xhttp.send();
推荐阅读
- javascript - jquery 可选择滚动,修复取消选择行为
- java - Android:铃声的自定义音频流
- javascript - 如何使用 Tampermonkey 远程控制用户脚本?如果发生某些事情,为其他用户启用/禁用脚本(以防我想更改。)
- ios - 我如何将 sms 中的代码自动填充到 6 个 UITextfields 中,每个 UITextfields 包含 1 个数字
- api - microsoft-teams 从过去的会议中创建会议统计信息
- c# - Xamarin Forms UWP 应用在发布商店文件后行为异常
- flutter - Flutter - 如何在传递值的同时从子级更改父级的主体小部件?
- ios - AppStoreConnect 订阅价格未显示
- laravel - Laravel 请求验证 required_if 有多个条件
- c# - 使用 gridview 字段中的按钮单击更新 SQL Server 表列