【发布时间】:2013-11-03 09:53:17
【问题描述】:
我有一个带有 autosized 属性的弹出窗口。面板包含用于搜索、搜索按钮、数据表和数据滚动条的字段。按下搜索按钮或在 datascroller 中选择页面后调用 javascript。 Javascript 用于将弹出窗口移动到浏览器可见区域的中心。一切正常,除了弹出阴影在弹出窗口已移动时保留在先前的面板位置。
按钮代码:
<a4j:commandButton id="searchButton"
value="#{msg.search}"
action="#{chAction.searchSegments}"
styleClass="richButton"
render="clientCategoryCandidateTable"
oncomplete="centerPanel();" />
Javascript:
function centerPanel() {
var modalPanel = #{rich:component('addToSegmentsPanel')};
var windowWidth = document.documentElement.clientWidth;
var windowHeight = document.documentElement.clientHeight;
var popupWidth = modalPanel.width();
var popupHeight = modalPanel.height();
modalPanel.setLeft(Math.max(0, (windowWidth-popupWidth)/2));
modalPanel.setTop(Math.max(0, (windowHeight-popupHeight)/2));
};
我尝试了不同版本的 javascript,但副作用相同:
function centerPopup() {
var popup = #{rich:component('addToSegmentsPanel')};
popup.moveTo(Math.max(0, (window.innerWidth-popup.width())/2),
Math.max(0, (window.innerHeight-popup.height())/2));
};
屏幕截图:
感谢任何帮助或 cmets。
【问题讨论】:
标签: javascript jsf-2 richfaces