Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 3 of 3
  1. #1
    Regular Coder
    Join Date
    Apr 2006
    Posts
    231
    Thanks
    9
    Thanked 1 Time in 1 Post

    Use Same Window/Reload

    I've got a popup script that opens videos in a popup window. The only problem is that when people click videos, each opens in new window and sometimes visitors forget to close one so the other just plays in the background. Is it possible to have a popup just reload the same window? (only one popup, and reloadthat one with new information if its open, otherwise open new popup.)

    Code:
    <SCRIPT type="text/javascript">
    <!-- Begin
    function popUp(URL) {
    day = new Date();
    id = day.getTime();
    eval("page" + id + " = window.open(URL, '" + id + "', 'toolbar=0,scrollbars=0,location=0,statusbar=0,menubar=0,resizable=0,width=500,height=500');");
    }
    // End -->
    </script>
    
    
    <a href=javascript:popUp('mvid.php?vid={$video[$K][$Name]}&type={$video[$K][$type]}')\">{$video[$K][$ID]}</a><br />;

  • #2
    Senior Coder coothead's Avatar
    Join Date
    Jan 2004
    Location
    chertsey, a small town 25 miles south west of london, england.
    Posts
    1,695
    Thanks
    0
    Thanked 232 Times in 227 Posts
    Hi there Erindesign,

    the script that you are using will prevent those who have javascript disabled from viewing the videos.
    This example will open new windows...
    Code:
    
    <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN"
       "http://www.w3.org/TR/html4/strict.dtd">
    <html>
    <head>
    <title></title>
    <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
    
    <style type="text/css">
    <!--
    #container li {
        margin:10px 0;
     }
    a.popup  {
        font-family:verdana,arial,helvetica,sans-serif;
        font-size:16px;
        color:#000;
     }
    a.popup:hover {
        color:#f96;
     }
    -->
    </style>
    
    <script type="text/javascript">
    <!--
    
    window.onload=function() {
      var mywindow;
      var w=600;
      var h=400;
      var l=(screen.width-w)/2;
      var t=(screen.width-h)/2;
      var features='width='+w+',height='+h+',left='+l+',top='+t+',scrollbars=yes';
      var lnk=document.getElementById('container').getElementsByTagName('a');
    for(c=0;c<lnk.length;c++) {
    lnk[c].onclick=function() {
    if(mywindow) {
       mywindow.close();
     }
       mywindow=window.open(this.href,'',features);
       mywindow.focus();
       return false;
       }
      }
     }
    
    //-->
    </script>
    
    </head>
    <body>
    
    <ul id="container">
    <li><a class="popup" href="http://www.google.com">google</a></li>
    <li><a class="popup" href="http://www.codingforums.com">codingforums</a></li>
    <li><a class="popup" href="http://www.w3c.org">w3c.org</a></li>
    <li><a class="popup" href="http://www.w3schools.com">w3schools</a></li>
    </ul>
    
    </body>
    </html>
    
    coothead

  • #3
    Regular Coder
    Join Date
    Apr 2006
    Posts
    231
    Thanks
    9
    Thanked 1 Time in 1 Post
    Well, what should I do? Is there any way of making a pop up in other ways?

    btw I fixed the original problem.


  •  

    Posting Permissions

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