Results 1 to 2 of 2

Thread: Help with DHTML window code :(

  1. #1
    Join Date
    Jan 2006
    Posts
    1
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Help with DHTML window code :(

    Hello, Ive been trying to figure this out for about 30 minutes now and I must say that I am stumped.
    Basically Ive designed a page that allows the user to click on a link to open a DHTML window with content. The idea is that there will be 3 different links, all wich open a different dhtml window containing each links sepereate contents. however, everytime a link is clicked, it opens each seperate windows contents but the header, stays the same for bothe windows :P

    Both windows have "wallpaper" as the header while one should say Audio and the other Wallpaper.

    Any help would be greatly appreciated!

    heres the code:

    <script>

    //DHTML Window script- Copyright Dynamic Drive (http://www.dynamicdrive.com)
    //For full source code, documentation, and terms of usage,
    //Visit http://www.dynamicdrive.com/dynamici...htmlwindow.htm

    var dragapproved=false
    var minrestore=0
    var initialwidth,initialheight
    var ie5=document.all&&document.getElementById
    var ns6=document.getElementById&&!document.all

    function iecompattest(){
    return (!window.opera && document.compatMode && document.compatMode!="BackCompat")? document.documentElement : document.body
    }

    function drag_drop(e){
    if (ie5&&dragapproved&&event.button==1){
    document.getElementById("dwindow").style.left=tempx+event.clientX-offsetx+"px"
    document.getElementById("dwindow").style.top=tempy+event.clientY-offsety+"px"
    }
    else if (ns6&&dragapproved){
    document.getElementById("dwindow").style.left=tempx+e.clientX-offsetx+"px"
    document.getElementById("dwindow").style.top=tempy+e.clientY-offsety+"px"
    }
    }

    function initializedrag(e){
    offsetx=ie5? event.clientX : e.clientX
    offsety=ie5? event.clientY : e.clientY
    document.getElementById("dwindowcontent").style.display="none" //extra
    tempx=parseInt(document.getElementById("dwindow").style.left)
    tempy=parseInt(document.getElementById("dwindow").style.top)

    dragapproved=true
    document.getElementById("dwindow").onmousemove=drag_drop
    }

    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+"px"
    document.getElementById("dwindow").style.height=initialheight=height+"px"
    document.getElementById("dwindow").style.left="30px"
    document.getElementById("dwindow").style.top=ns6? window.pageYOffset*1+30+"px" : iecompattest().scrollTop*1+30+"px"
    document.getElementById("cframe").src=url
    }
    }

    function maximize(){
    if (minrestore==0){
    minrestore=1 //maximize window
    document.getElementById("maxname").setAttribute("src","restore.gif")
    document.getElementById("dwindow").style.width=ns6? window.innerWidth-20+"px" : iecompattest().clientWidth+"px"
    document.getElementById("dwindow").style.height=ns6? window.innerHeight-20+"px" : iecompattest().clientHeight+"px"
    }
    else{
    minrestore=0 //restore window
    document.getElementById("maxname").setAttribute("src","max.gif")
    document.getElementById("dwindow").style.width=initialwidth
    document.getElementById("dwindow").style.height=initialheight
    }
    document.getElementById("dwindow").style.left=ns6? window.pageXOffset+"px" : iecompattest().scrollLeft+"px"
    document.getElementById("dwindow").style.top=ns6? window.pageYOffset+"px" : iecompattest().scrollTop+"px"
    }

    function closeit(){
    document.getElementById("dwindow").style.display="none"
    }

    function stopdrag(){
    dragapproved=false;
    document.getElementById("dwindow").onmousemove=null;
    document.getElementById("dwindowcontent").style.display="" //extra
    }

    </script>
    -----------------------Second DHTML WINDOW--------------------------------
    <script>

    //DHTML Window script- Copyright Dynamic Drive (http://www.dynamicdrive.com)
    //For full source code, documentation, and terms of usage,
    //Visit http://www.dynamicdrive.com/dynamici...htmlwindow.htm

    var dragapproved=false
    var minrestore=0
    var initialwidth,initialheight
    var ie5=document.all&&document.getElementById
    var ns6=document.getElementById&&!document.all

    function iecompattest(){
    return (!window.opera && document.compatMode && document.compatMode!="BackCompat")? document.documentElement : document.body
    }

    function drag_drop(e){
    if (ie5&&dragapproved&&event.button==1){
    document.getElementById("dwindow2").style.left=tempx+event.clientX-offsetx+"px"
    document.getElementById("dwindow2").style.top=tempy+event.clientY-offsety+"px"
    }
    else if (ns6&&dragapproved){
    document.getElementById("dwindow2").style.left=tempx+e.clientX-offsetx+"px"
    document.getElementById("dwindow2").style.top=tempy+e.clientY-offsety+"px"
    }
    }

    function initializedrag(e){
    offsetx=ie5? event.clientX : e.clientX
    offsety=ie5? event.clientY : e.clientY
    document.getElementById("dwindowcontent2").style.display="none" //extra
    tempx=parseInt(document.getElementById("dwindow2").style.left)
    tempy=parseInt(document.getElementById("dwindow2").style.top)

    dragapproved=true
    document.getElementById("dwindow2").onmousemove=drag_drop
    }

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

    function maximize(){
    if (minrestore==0){
    minrestore=1 //maximize window
    document.getElementById("maxname2").setAttribute("src","restore.gif")
    document.getElementById("dwindow2").style.width=ns6? window.innerWidth-20+"px" : iecompattest().clientWidth+"px"
    document.getElementById("dwindow2").style.height=ns6? window.innerHeight-20+"px" : iecompattest().clientHeight+"px"
    }
    else{
    minrestore=0 //restore window
    document.getElementById("maxname2").setAttribute("src","max.gif")
    document.getElementById("dwindow2").style.width=initialwidth
    document.getElementById("dwindow2").style.height=initialheight
    }
    document.getElementById("dwindow2").style.left=ns6? window.pageXOffset+"px" : iecompattest().scrollLeft+"px"
    document.getElementById("dwindow2").style.top=ns6? window.pageYOffset+"px" : iecompattest().scrollTop+"px"
    }

    function closeit(){
    document.getElementById("dwindow2").style.display="none"
    }

    function stopdrag(){
    dragapproved=false;
    document.getElementById("dwindow2").onmousemove=null;
    document.getElementById("dwindowcontent2").style.display="" //extra
    }

    </script>

    <script type="text/javascript">
    //

    //Generate transition CSS (transition=0 to 23)
    document.write('<STYLE TYPE="text/css">.imgTrans{ filter:revealTrans(duration=0.4,transition=12) }</STYLE>');

    //Uncomment the next line for fading rollovers instead of dissolving:
    document.write('<STYLE TYPE="text/css">.imgTrans{ filter:blendTrans(duration=1.4) }</STYLE>');

    var onImages=new Array();
    function Rollover(imgName, imgSrc)
    {
    onImages[imgName] = new Image();
    onImages[imgName].src = imgSrc;
    }

    function turnOn(imgName){
    if(document.images[imgName].filters != null)
    document.images[imgName].filters[0].apply();
    document.images[imgName].offSrc = document.images[imgName].src;
    document.images[imgName].src = onImages[imgName].src;
    if(document.images[imgName].filters != null)
    document.images[imgName].filters[0].play();
    }

    function turnOff(imgName){
    if(document.images[imgName].filters != null)
    document.images[imgName].filters[0].stop();
    document.images[imgName].src = document.images[imgName].offSrc;
    }

    //Specify name of participating images, plus paths to their onMouseover replacements:
    Rollover("audio", "/images/audio.jpg");
    Rollover("wall", "/images/wall.jpg");
    Rollover("misc", "/images/misc.jpg");
    </script>

    </head>
    <body background="/images/splash.jpg">

    <div id="dwindow" style="position:absolute;background-color:#EBEBEB;cursor:hand;left:0px;top:0px;display:none" onMousedown="initializedrag(event)" onMouseup="stopdrag()" onSelectStart="return false">
    <div align="left" style="background-color:#32469D"><font color="#ffffff" face="verdana">-Audio<img src="max.gif" id="maxname" onClick="maximize()"><img src="close.gif" onClick="closeit()"></div>
    <div id="dwindowcontent" style="height:100%">
    <iframe id="cframe" src="" width=100% height=100%></iframe>
    </div>
    </div>
    <script>

    </script>
    <!--Use below code to load DHTML window via link-->
    <a href="javascript:loadwindow('audio.html',400,250)"
    onMouseOver="turnOn('audio');"
    onMouseOut="turnOff('audio');"><img name="audio" class="imgTrans"
    src="/images/audioz.jpg" border="0"></a><br>

    <div id="dwindow2" style="position:absolute;background-color:#EBEBEB;cursor:hand;left:0px;top:0px;display:none" onMousedown="initializedrag(event)" onMouseup="stopdrag()" onSelectStart="return false">

    <div align="left" style="background-color:#32469D"><font color="#ffffff" face="verdana">-Wallpaper<img src="max.gif" id="maxname2" onClick="maximize()"><img src="close.gif" onClick="closeit()"></div>
    <div id="dwindowcontent2" style="height:100%">
    <iframe id="cframe2" src="" width=100% height=100%></iframe>
    </div>
    </div>

    <script>

    </script>
    <br>
    <!--Use below code to load DHTML window via link-->
    <a href="javascript:loadwindow('wallpaper.html',400,250)"
    onMouseOver="turnOn('wall');"
    onMouseOut="turnOff('wall');"><img name="wall" class="imgTrans"
    src="/images/wallz.jpg" border="0"></a><br>

  2. #2
    Join Date
    Oct 2005
    Posts
    63
    Thanks
    5
    Thanked 1 Time in 1 Post

    Default

    Can you post a link to your page?

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •