Create the Dynamic HTML window using Java Script

Hi Friends, I have written this JS script which creates eggheadcafe DHTML window. Your questions are most welcomed. -Jack

<HEAD>

<script language="javascript">

var IE_elements=document.all&&document.getElementById
var other_elements=document.getElementById&&!document.all
var flag=false var restore_flag=0 var wwidth,wheight function MyDragAndDrop(e){ if (IE_elements&&flag&&event.button==1){
document.getElementById("mywindow").style.left=tempx+event.clientX-offsetx+"px" document.getElementById("mywindow").style.top=tempy+event.clientY-offsety+"px" } else if (other_elements&&flag){
document.getElementById("mywindow").style.left=tempx+e.WinX-offsetx+"px" document.getElementById("mywindow").style.top=tempy+e.WinY-offsety+"px" } } function Window_Drag_Finished(){ flag=false;
document.getElementById("mywindow").onmousemove=null;
document.getElementById("mywindowcontent").style.display="" //extra } function checkIE(){ return (!window.opera && document.compatMode && document.compatMode!="BackCompat")? document.documentElement : document.body
}

function Initialization(e){
offsetx=IE_elements? event.clientX : e.WinX
offsety=IE_elements? event.clientY : e.WinY
document.getElementById("mywindowcontent").style.display="none" //extra tempx=parseInt(document.getElementById("mywindow").style.left)
tempy=parseInt(document.getElementById("mywindow").style.top)
flag=true document.getElementById("mywindow").onmousemove=MyDragAndDrop
}

function Window_Load(url,width,height){
if (!IE_elements&&!other_elements)
window.open(url,"","width=width,height=height,scrollbars=1")
else{
document.getElementById("mywindow").style.display='' document.getElementById("mywindow").style.width=wwidth=width+"px" document.getElementById("mywindow").style.height=wheight=height+"px" document.getElementById("mywindow").style.left="30px" document.getElementById("mywindow").style.top=other_elements? window.pageYOffset*1+30+"px" : checkIE().scrollTop*1+30+"px" document.getElementById("cframe").src=url
}
}

function Window_Maximized(){
if (restore_flag==0){
restore_flag=1 //Window_Maximized window document.getElementById("maxname").setAttribute("src","restore.gif")
document.getElementById("mywindow").style.width=other_elements? window.innerWidth-20+"px" : checkIE().clientWidth+"px" document.getElementById("mywindow").style.height=other_elements? window.innerHeight-20+"px" : checkIE().clientHeight+"px" } else{
restore_flag=0 //restore window document.getElementById("maxname").setAttribute("src","max.gif")
document.getElementById("mywindow").style.width=wwidth
document.getElementById("mywindow").style.height=wheight
}
document.getElementById("mywindow").style.left=other_elements? window.pageXOffset+"px" : checkIE().scrollLeft+"px" document.getElementById("mywindow").style.top=other_elements? window.pageYOffset+"px" : checkIE().scrollTop+"px" } function Window_Close(){ document.getElementById("mywindow").style.display="none" } </script> </HEAD> <BODY> <div id="mywindow" style="position:absolute;background-color:#EBEBEB;cursor:hand;left:0px;top:0px;display:none" onMousedown="initializedrag(event)" onMouseup="Window_Drag_Finished()" onSelectStart="return false">
<div align="right" style="background-color:navy"><img src="max.gif" id="maxname" onClick="maximize()"><img src="close.gif" onClick="Window_Close()"></div>
<div id="mywindowcontent" style="height:100%">
<iframe id="cframe" src="" width=100% height=100%></iframe>
</div>
</div>

<script>
//load DHTML Window on page load if (other_elements) window.onload=new Function('Window_Load("http://www.eggheadcafe.com",600,400)')
else Window_Load("http://www.eggheadcafe.com",600,400)
</script>

<!--load DHTML window using link-->
<a href="javascript:loadwindow('http://www.eggheadcafe.com',600,400)"></a>
</BODY>
By Jignesh Shah   Popularity  (2638 Views)
Biography - Jignesh Shah
"I am electric engg and professor in college. Working on all the softwar languages are my passion." - Jignesh