Hello Chaps,
I'm looking for a piece of code that will allow me to dynamically write HTML to a pop-up window, where I can specify the dimensions of the window, and other custom bits and pieces, and where the pop-up will sit in the very center of the page/viewport.

I currently have a script that will allow me to write the info I need to a window, but it needs absolute positioning, which is no good to me. I also have a script that opens a pop-up in the very center of the page, that contains a specified url. This is also no good, as I want to write the html content into the link that launches the pop-up, rather than have a separate html document for every pop-up.

here is the "Write to pop-up" code (Goes in <head>):
<SCRIPT Language="JavaScript">
var win1Open = null


function displayImage(picName, windowName, windowWidth, windowHeight, textBlock){
return window.open(picName,windowName,"toolbar=no,scrollbars=no,resizable=no,screenX=200px,screenY=200px,top=300px,left=400px,width=" + (parseInt(windowWidth)+20) + ",height=" + (parseInt(windowHeight)+15))
}

function winClose(){ // close all open pop-up windows
if(win1Open != null) win1Open.close()

}

function doNothing(){} // does nothing but required by JavaScript in this case
</SCRIPT>

<SCRIPT Language="JavaScript1.1"> // improved displayImage function for Netscape 3+ and IE 4+
function displayImage(picName, windowName, windowWidth, windowHeight, textBlock, mp3Name){
var winHandle = window.open("" ,windowName,"toolbar=no,scrollbars=no,resizable=no,screenX=200px,screenY=200px,top=300px,left=400px,width=" + windowWidth + ",height=" + windowHeight)
if(winHandle != null){
var htmlString = "<html><head><title>TITLE</title></head>"
htmlString += "<body bgcolor='#000000' topmargin='0' marginheight='0' leftmargin='0' marginwidth='0'>"
htmlString += "<br><font style='font-family: Arial, sans-serif; font-size: 18px; color: #ffffff;'><center>" + textBlock + "</font><br><br>"
htmlString += "<embed ID='audioClip' name='audioClip' src='" + mp3Name + ".mp3' ShowTracker='1' ShowStatusBar='0' ShowControls='1' ShowDisplay='0' width='200' height='75' autostart='true'><br>"

htmlString += "<font style='font-family: Arial, sans-serif; font-size: 10px; color: #ffffff;'>(Please wait while clip loads)</font><br><br>"

htmlString += "<form><input type=button value='Close Window' onClick='javascript:window.close();'></form>"
htmlString += "</body></html>"
winHandle.document.open()
winHandle.document.write(htmlString)
winHandle.document.close()
}
if(winHandle != null) winHandle.focus() //brings window to top
return winHandle
}
</SCRIPT>
And here is the an example of the link that launches it:

<A HREF="JAVASCRIPT:doNothing()" onClick="win1Open=displayImage('', 'popWin1', '300', '245', 'Unbreakable', 'unbreakable')" >LAUNCH POP-UP</A>
Here too is the script that will center a window for me (Also goes in <head>:

<script language="JavaScript1.2">

function OpenBrWindow(theURL,winName,features, myWidth, myHeight, isCenter) { //v3.0

if(window.screen)if(isCenter)if(isCenter=="true"){

var myLeft = (screen.width-myWidth)/2;

var myTop = (screen.height-myHeight)/2;

features+=(features!='')?',':'';

features+=',left='+myLeft+',top='+myTop;

}

window.open(theURL,winName,features+((features!='')?',':'')+'width='+myWidth+',height='+myHeight);

}

</script>
And the link that launches it:

<a href="javascript:;" onClick="OpenBrWindow('URL.html','Test2','toolbar=no,location=no,status=no,menubar=no,scrollbars=no,resizable=no','400','350','true')">LAUNCH POP-UP</a>
Can anyone help with combining these two things for me, or providing me with a script that will allow me both features? I'll be very grateful for any input at all, as it's driving me slightly mad...

Many thanks in anticipation,

Nathan