PDA

View Full Version : Can a loadwindow function be center when entering a page?


Lynne
01-07-2003, 09:28 PM
Right now popup window is positioned from left and top. I want it to be centered automatically. Is it possible? If so, what code would I need?

function loadwindow(url,width,height){
if (!ie5&&!ns6)
window.open(url,"","width=width,height=height,scrollbars=1")
else{
document.getElementById("dwindow").style.display=''
document.getElementById("dwindow").style.width=initialwidth=width
document.getElementById("dwindow").style.height=initialheight=height
document.getElementById("dwindow").style.left=30
document.getElementById("dwindow").style.top=ns6? window.pageYOffset*1+30 : document.body.scrollTop*1+30
document.getElementById("cframe").src=url
}

Mr J
01-07-2003, 10:02 PM
<script language="JavaScript" type="text/javascript">
<!--
function popWin(url){
var Width = 500
var Height = 400
var posX = (screen.availWidth - Width) / 2
var posY = (screen.availHeight - Height) / 2

var popUp = window.open(url,'pop','width='+Width+',height='+Height+',left='+posX+',top='+posY+',scrollbars=yes,r esizable=yes')
popUp.focus()
}
// -->
</script>

<a href="#null" onClick="popWin('yourpage.htm')">Pop 1</a>

Lynne
01-08-2003, 02:34 PM
Thanks! I'll try it out and see how it does...