Results 1 to 7 of 7

Thread: Closing window automatically?

  1. #1
    Join Date
    Mar 2007
    Posts
    3
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Closing window automatically?

    Hi,
    I open a avi that plays in a new window, how can I get the window to close when the avi is done playing?
    thanks for the help!!
    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
    <html>
    <head>
    <title>Movie Titles</title>
    <style type="text/css">

    .basictab ul{
    margin: 4px;
    padding: 3px 0;
    margin-left: 0;
    font: bold 12px Verdana;
    border-bottom: 1px solid gray;
    list-style-type: none;
    text-align: left; /*set to left, center, or right to align the menu as desired*/
    }

    .basictab li{
    display: inline;
    margin: 0;
    }

    .basictab li a{
    text-decoration: none;
    padding: 3px 7px;
    margin-right: 3px;
    border: 1px solid gray;
    border-bottom: none;
    background-color: #f6ffd5;
    color: #2d2b2b;
    }

    .basictab li a:visited{
    color: #2d2b2b;
    }

    .basictab li a:hover, .basictab li a.current{
    background-color: #DBFF6C;
    color: black;
    }

    .basictab li a:active{
    color: black;
    }

    #tabcontentcontainer{
    width:95%; /*width of 2nd level content*/
    height:1.5em; /*height of 2nd level content. Set to largest's content height to avoid jittering.*/
    }

    .tabcontent{
    display:none;
    }

    </style>


    <script type="text/javascript">

    /***********************************************
    * DD Tab Menu script- © Dynamic Drive DHTML code library (www.dynamicdrive.com)
    * This notice MUST stay intact for legal use
    * Visit Dynamic Drive at http://www.dynamicdrive.com/ for full source code
    ***********************************************/

    //Set tab to intially be selected when page loads:
    //[which tab (1=first tab), ID of tab content to display (or "" if no corresponding tab content)]:
    var initialtab=[1, "sc1"]

    //Turn menu into single level image tabs (completely hides 2nd level)?
    var turntosingle=0 //0 for no (default), 1 for yes

    //Disable hyperlinks in 1st level tab images?
    var disabletablinks=0 //0 for no (default), 1 for yes


    ////////Stop editting////////////////

    var previoustab=""

    if (turntosingle==1)
    document.write('<style type="text/css">\n#tabcontentcontainer{display: none;}\n</style>')

    function expandcontent(cid, aobject){
    if (disabletablinks==1)
    aobject.onclick=new Function("return false")
    if (document.getElementById && turntosingle==0){
    highlighttab(aobject)
    if (previoustab!="")
    document.getElementById(previoustab).style.display="none"
    if (cid!=""){
    document.getElementById(cid).style.display="block"
    previoustab=cid
    }
    }
    }

    function highlighttab(aobject){
    if (typeof tabobjlinks=="undefined")
    collectddtabs()
    for (i=0; i<tabobjlinks.length; i++)
    tabobjlinks[i].className=""
    aobject.className="current"
    }

    function collectddtabs(){
    var tabobj=document.getElementById("ddtabs")
    tabobjlinks=tabobj.getElementsByTagName("A")
    }

    function do_onload(){
    collectddtabs()
    expandcontent(initialtab[1], tabobjlinks[initialtab[0]-1])
    }

    if (window.addEventListener)
    window.addEventListener("load", do_onload, false)
    else if (window.attachEvent)
    window.attachEvent("onload", do_onload)
    else if (document.getElementById)
    window.onload=do_onload

    </script>
    </head>

    <body bgcolor="#FFFFCC" text="#660099" link="#FF3399" vlink="#669966" alink="#CC3333">

    <div id="ddtabs" class="basictab">
    <ul>
    <li><a href="c:\test\nickytest.html" onMouseover="expandcontent('sc1', this)">Back to MAIN menu</a></li>
    </ul>
    <div>

    <DIV id="tabcontentcontainer">


    <div id="sc1" class="tabcontent">
    <u><div align="center"><center><b><strong><u><font face="times new roman, times, serif"><font color="#003333"></font></font></strong></u></b></center></div></u>
    </div>

    </DIV>
    </body>
    </html>

    <body bgcolor="#FFFFCC">
    <table border="2" cellspacing="5" cellpadding="5" width="100%" bgcolor="#ffffcc" bordercolorlight="#330000" bordercolordark="">

    </body>
    </html>
    <tr>
    <td><a href="c:\test\Sahara.avi" onclick="var win=window.open('','mywindow','height=600, width=1000');win.document.write('\x3Chtml\x3E\x3Chead\x3E\x3Ctitle\x3EBlockBusters\x3C/title\x3E\x3Cstyle\x3Ehtml,body {margin:0;padding:0;}\x3C/style\x3E\x3C/head\x3E\x3Cbody\x3E\x3Cembed src=\'c:/test/Sahara.avi\' width=\'1000\' height=\'600\' autostart=\'1\' showcontrols=\'0\' type=\'application/x-mplayer2\' pluginspage=\'http://www.microsoft.com/windows/windowsmedia/download/\'\x3E \x3C/embed\x3E\x3C/body\x3E\x3C/html\x3E');return false;">Sahara</a><br></td>
    </tr>

  2. #2
    Join Date
    Feb 2007
    Posts
    293
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    You could add code to close the window after a set period of time, ie the length of the movie, plus a bit of padding to make sure it doesn't close before the movie is done.

    setTimeout('self.close();',30000);

    The number is in milliseconds, so 30000 equals 30 seconds

  3. #3
    Join Date
    Feb 2007
    Posts
    116
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    I would use start the timer with the onload event so that it takes the loading time in to account.
    "Rock and roll ain't noise pollution." - AC/DC

    http://www.blake-foster.com

  4. #4
    Join Date
    Mar 2007
    Posts
    3
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    Hi thanks, but where would I put the statement setTimeout('self.close();',3000)?

  5. #5
    Join Date
    Feb 2007
    Posts
    116
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    Code:
    <td><a href="c:\test\Sahara.avi" onclick="var win=window.open('','mywindow','height=600, width=1000');win.document.write('\x3Chtml\x3E\x3Chead\x3E\x3Ctitle\x3EBlockBusters\x3C/title\x3E\x3Cstyle\x3Ehtml,body {margin:0;padding:0;}\x3C/style\x3E\x3C/head\x3E\x3Cbody\x3E\x3Cembed onload=\"setTimeout(\'self.close();\',3000)\" src=\'c:/test/Sahara.avi\' width=\'1000\' height=\'600\' autostart=\'1\' showcontrols=\'0\' type=\'application/x-mplayer2\' pluginspage=\'http://www.microsoft.com/windows/windowsmedia/download/\'\x3E \x3C/embed\x3E\x3C/body\x3E\x3C/html\x3E');return false;">Sahara</a><br></td>
    By the way, that code is absolutely unreadable. It would be a good idea to put the onclick event in a function:

    Code:
    <script type = "text/javascript">
    
    function openWindow()
    {
      var win=window.open('','mywindow','height=600,width=1000');
      win.document.write('<html><head><title>BlockBusters</title></head><body>');
      win.document.write('<embed src="c:/test/Sahara.avi" width="1000" onload="setTimeout(\'self.close();\', 3000);"');
      win.document.write('width="1000" height="600" autostart="1" showcontrols="0" type="application/x-mplayer2"');
      win.document.write('pluginspage="http://www.microsoft.com/windows/windowsmedia/download/"></embed>');
      win.document.write('</body></html>');
      return false;
    }
    
    </script>
    
    <a href="test\Sahara.avi" onclick="return openWindow();">Sahara</a>
    Last edited by Blake; 03-09-2007 at 02:29 PM.
    "Rock and roll ain't noise pollution." - AC/DC

    http://www.blake-foster.com

  6. #6
    Join Date
    Mar 2007
    Posts
    3
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    Hi Blake, I finally got aroung testing this, but it does not close the window in which the avi file is played in, could it be IE, I'm using version 6, also this
    <td><a href="c:\test\Sahara.avi" onclick="var win=window.open('','mywindow','height=600, width=1000');win.document.write('\x3Chtml\x3E\x3Chead\x3E\x3Ctitle\x3EBlockBusters\x3C/title\x3E\x3Cstyle\x3Ehtml,body {margin:0;padding:0;}\x3C/style\x3E\x3C/head\x3E\x3Cbody\x3E\x3Cembed onload=\"setTimeout(\'self.close();\',3000)\" src=\'c:/test/Sahara.avi\' width=\'1000\' height=\'600\' autostart=\'1\' showcontrols=\'0\' type=\'application/x-mplayer2\' pluginspage=\'http://www.microsoft.com/windows/windowsmedia/download/\'\x3E \x3C/embed\x3E\x3C/body\x3E\x3C/html\x3E');return false;">Sahara</a><br></td>
    Plays the avi in the current window, IE does not open a new one
    Any ideas please?
    Thanks

  7. #7
    Join Date
    Sep 2006
    Location
    St. George, UT
    Posts
    2,769
    Thanks
    3
    Thanked 157 Times in 155 Posts

    Default

    If I'm not mistaken, this part:

    Code:
    \x3Cembed onload=\"setTimeout(\'self.close();\',3000)\"
    should be this:

    Code:
    onload=\"setTimeout(\'self.close();\',3000)\"
    because there is no "embed" attribute in the body tag.
    Hope this helps.
    "Computer games don't affect kids; I mean if Pac-Man affected us as kids, we'd all be running around in darkened rooms, munching magic pills and listening to repetitive electronic music." - Kristian Wilson, Nintendo, Inc, 1989
    TheUnlimitedHost | The Testing Site | Southern Utah Web Hosting and Design

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
  •