The code below opens a window and creates a close button.
I can get the window to close by using <button onClick="window.close()"> but I want to do this using the function closeWindow() as shown.
What am I missing here? It should be fairly simple.
Thanks,
I can get the window to close by using <button onClick="window.close()"> but I want to do this using the function closeWindow() as shown.
What am I missing here? It should be fairly simple.
Thanks,
Code:
<html>
<head>
<title>New Page 1</title>
</head>
<body>
<script language="JavaScript" type="text/JavaScript">
function closeWindows(){
window.close();
//jkpopwin.window.close()
}
popwidth=400;
popheight=450;
leftpos1=420;
toppos=210;
popbackground="orange";
textdescription="TEXT HERE";
var winattributes='width='+popwidth+',height='+popheight+',resizable=no,left='+leftpos1+',top='+toppos
var bodyattribute=(popbackground.indexOf(".")!=-1)? 'background="'+popbackground+'"' : 'bgcolor="'+popbackground+'"'
if (typeof jkpopwin=="undefined" || jkpopwin.closed)
jkpopwin=window.open("","",winattributes)
else{
//getpos() //uncomment these 2 lines if you wish subsequent popups to be centered too
//jkpopwin.moveTo(leftpos, toppos)
jkpopwin.resizeTo(popwidth, popheight+30)
}
jkpopwin.document.open()
jkpopwin.document.write('<html><title>test</title><head></head> <body '+bodyattribute+' ><center><br><br>'+textdescription+'<BR><BR>[b]<BUTTON onClick="closeWindow()">Close Window</BUTTON>[/b]</center></body></html>')
jkpopwin.document.close()
jkpopwin.focus()
</script>
</body>
</html>