www.webdeveloper.com
Page 2 of 2 FirstFirst 12
Results 16 to 21 of 21

Thread: opening multiple urls using window.open function

  1. #16
    Join Date
    Feb 2008
    Posts
    1,666
    Post #7 above was missing it so I wondered... had to make sure.

  2. #17
    Join Date
    Feb 2008
    Posts
    1,666
    I do it this way so that if JavaScript is disabled, the link still works:
    HTML Code:
    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
                          "http://www.w3.org/TR/html4/loose.dtd">
    <html>
    <head>
    <meta http-equiv="Content-Language" content="en-us">
    <meta http-equiv="Content-Type" content="text/html; charset=windows-1252">
    <title>Popup Links</title>
    <script type="text/javascript">
    <!--//
    function poponload(url, tgt)
    {
        var testwindow = window.open (url, tgt, "location=no,status=0,scrollbars=0,menubar=0,resizable=0,toolbar=0,directories=0,width=750,height=550");
    //  testwindow.moveTo(25,40);
        return false;
    }
    //-->
    </script>
    </head>
    
    <body>
    
    <p><a href="http://www.google.com/" target="_blank"
     onclick="return poponload(this.href, this.target)">Google</a></p>
    <p><a href="http://www.yahoo.com/" target="_blank"
     onclick="return poponload(this.href, this.target)">Yahoo</a></p>
    
    </body>
    </html>
    Your moveTo is commented out because it was causing an error -- as I suggested several posts ago.

  3. #18
    Join Date
    Jan 2008
    Location
    KnowledgeVille
    Posts
    36
    Quote Originally Posted by MrNobody View Post
    I noticed in your function that you are missing a parameter. This is what I posted for you to use. Note the part in red:
    Code:
    function poponload(url)
    {
        var testwindow = window.open (url, "mywindow","location=no,status=0,scrollbars=0,menubar=0,resizable=0,toolbar=0,directories=0,width=750,height=550");
        testwindow.moveTo(25,40);
    }
    ok. I realized now that it may be my php syntax. I was successful in launching the website without my php coding. If you have any suggestions for the above php script, please post. Meanwhile i will be researching php syntax. Thanks for all your help and future help. O. Im using PHP version 4.4.8

  4. #19
    Join Date
    Jan 2008
    Location
    KnowledgeVille
    Posts
    36
    Yes....ok i got it now!!! (with your help of course)... below is the code i used
    Thanks again for not giving up on me

    PHP Code:

    <?php
     session_start
    ();
    ?>
      



    <HTML>


    <head>
    <title>popup</title>


    </head>

    <script type="text/javascript">
    <!--
    function popup(url) 
    {
     var width  = 900;
     var height = 800;
     var left   = (screen.width  - width)/2;
     var top    = (screen.height - height)/2;
     var params = 'width='+width+', height='+height;
     params += ', top='+top+', left='+left;
     params += ', directories=no';
     params += ', location=no';
     params += ', menubar=no';
     params += ', resizable=no';
     params += ', scrollbars=no';
     params += ', status=no';
     params += ', toolbar=no';
     newwin=window.open(url,'windowname5', params);
     if (window.focus) {newwin.focus()}
     return false;
    }
    // -->
    </script>

    <body>

    <?php
      
      
    // check session variable

      
    if (isset($_SESSION['valid_user']))
      {
        
           echo 
    '<tr align="center" bgcolor="#39275B"><td colspan="3">';
        echo 
    '<a href="javascript: void()"    onclick="popup(\'http://www.mysite.com/secure/me.pdf\')" class="linkw">Application</a>';
        echo 
    '</td></tr>';
        
        
        echo 
    '<tr align="center" bgcolor="#39275B"><td colspan="3">';
        echo 
    '<a href="javascript: void()" onclick="popup(\'http://www.google.com/ig\')" class="linkw">Application</a>';
        echo 
    '</td></tr>';
        
        
        
        echo 
    '<tr align="center" bgcolor="#39275B"><td colspan="3">';
        echo 
    '<a href="javascript: void()" onclick="popup(\'defaultpage.php\')" class="linkw">Application</a>';
        echo 
    '</td></tr>';
        
              
       
        
      }
      else
      {
        echo 
    '<p>You are not logged in.</p>';
        echo 
    '<p>Only logged in members may view information on this page.</p>';
        echo 
    '<a href="h7.php" class="linkw">Back to main page please</a>';
        
      }

      
    ?>
    Just one last question....What is the reason for adding the comments (<!-- ... -->) within the javascript....It works with and without so why use it?

  5. #20
    Join Date
    Feb 2008
    Posts
    1,666
    It used to be a requirement in case the browser didn't support JavaScript -- that way, it would be commented out and not cause errors during page load. Browsers nowadays should be smart enough to skip the JavaScript code even if they don't support it. But, ya never know.

  6. #21
    Join Date
    Jan 2008
    Location
    KnowledgeVille
    Posts
    36
    Thanks for all your help!!

Thread Information

Users Browsing this Thread

There are currently 2 users browsing this thread. (0 members and 2 guests)

Tags for this Thread

Posting Permissions

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



Recent Articles