1、按钮:
<input type="button" class="btn btn-success " value="点击按钮" onclick="openPage();" />
2、方法:
function openPage(){
var openUrl="/xxx/yyy.jsp"; //转向网页的地址;
var openName="打开的页面"; //网页名称,可为空;
var iWidth=400; //弹出窗口的宽度;
var iHeight=200; //弹出窗口的高度;
//window.screen.height获得屏幕的高,window.screen.width获得屏幕的宽
var iTop = (window.screen.height-30-iHeight)/2; //获得窗口的垂直位置;
var iLeft = (window.screen.width-10-iWidth)/2; //获得窗口的水平位置;
window.open(openUrl,openName,'height='+iHeight+',,innerHeight='+iHeight+',
width='+iWidth+',innerWidth='+iWidth+',top='+iTop+',left='+iLeft+',
toolbar=no,menubar=no,scrollbars=no,
resizeable=no,location=no,status=no');
}
3、页面:
打开的页面script标签内
alert("操作调用当前页面的方法,即返回值"); window.opener.document.all.bigImgPath.value='<%=request.getAttribute("filename")%>'; window.opener.document.all.bigImgPoster.innerHTML='<%=request.getAttribute("filename")%>'; window.opener=null; window.open('','_self'); window.close();