jQuery를 불러온다.
<script type="text/javascript" src="/js/jquery-1.6.4.min.js"></script>
<script type="text/javascript">
// 레이어 보기
function objView(obj) {
var win = $(window);
var winH = win.scrollTop() + ((win.height() - $('#'+ obj).height()) / 2);
var winW = win.scrollLeft() + ((win.width() - $('#'+ obj).width()) / 2);
$('#'+ obj).css('top', winH);
$('#'+ obj).css('left', winW);
$('#'+ obj).show();
$('#'+ obj).focus();
}
// 레이어 숨기기
function objHide(obj) {
$('#'+ obj).hide();
}
</script>
<input type='button' value='보기' onClick='objView("dview");' style="cursor:pointer;" />
<div id="dview" style="position:absolute;z-index:21;display:none;">
<script type="text/javascript" src="/js/jquery-1.6.4.min.js"></script>
<script type="text/javascript">
// 레이어 보기
function objView(obj) {
var win = $(window);
var winH = win.scrollTop() + ((win.height() - $('#'+ obj).height()) / 2);
var winW = win.scrollLeft() + ((win.width() - $('#'+ obj).width()) / 2);
$('#'+ obj).css('top', winH);
$('#'+ obj).css('left', winW);
$('#'+ obj).show();
$('#'+ obj).focus();
}
// 레이어 숨기기
function objHide(obj) {
$('#'+ obj).hide();
}
</script>
<input type='button' value='보기' onClick='objView("dview");' style="cursor:pointer;" />
<div id="dview" style="position:absolute;z-index:21;display:none;">
중앙에 보일것이야!
<input type='button' value='안보기' onClick='objHide("dview");' style="cursor:pointer;" />
<input type='button' value='안보기' onClick='objHide("dview");' style="cursor:pointer;" />
</div>