www.webdeveloper.com
Page 1 of 2 12 LastLast
Results 1 to 15 of 21

Thread: opening multiple urls using window.open function

  1. #1
    Join Date
    Jan 2008
    Location
    KnowledgeVille
    Posts
    36

    opening multiple urls using window.open function

    Greetings:
    I'm trying to creating a function which allows me to enter the url link in the body of the code when calling the window.open function.

    Currently my code is written as followed...
    Code:
    <SCRIPT language="JavaScript1.2">
    function poponload()
    {
    testwindow= window.open ("", "mywindow","location=no,status=0,scrollbars=0,menubar=0,resizable=0,toolbar=0,directories=0,width=750,height=550");
    testwindow.moveTo(25,40);
    }
    </SCRIPT>
    
    
    <body style="background: #39275B; 
      background-attachment: fixed;
      background-repeat: no-repeat;  
      background-position: center;
    link="white" vlink="red" alink="white"">
    
    
    <font face="Verdana, Arial, Helvetica, sans-serif" size="2" color="#FFFFFF">
    <li type="circle">
    <a href="javascript: poponload()" class="linkw">Application</a>
    </font></li>
    
    </body>
    </html>


    I would like to enter a different url link each time i call the function
    Like the example below
    Code:
    <a href="javascript: poponload(http://www.google.com)" class="linkw">Application</a>
    
    <a href="javascript: poponload(/secure/mlu/Henderson.pdf)" class="linkw">Application</a>
    
    <a href="javascript: poponload(/secure/ucla/And.html)" class="linkw">Application</a>
    
    <a href="javascript: poponload(http://www.webdeveloper.com)" class="linkw">Application</a>
    Any help is greatly appreciated

  2. #2
    Join Date
    Feb 2008
    Posts
    1,666
    Just put the different URL's inside of single quotes and do this:
    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);
    }

  3. #3
    Join Date
    Jan 2008
    Location
    KnowledgeVille
    Posts
    36
    Thanks but i receive a syntax error when i do the following...

    Code:
    <SCRIPT language="JavaScript1.2">
    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);
    }
    </SCRIPT>
    
    <body style="background: #39275B; 
      background-attachment: fixed;
      background-repeat: no-repeat;  
      background-position: center;
    link="white" vlink="red" alink="white"">
    
    
    <font face="Verdana, Arial, Helvetica, sans-serif" size="2" color="#FFFFFF">
    <li type="circle">
    <a href="javascript: poponload('http://www.google.com')" class="linkw">Application</a>
    
    <a href="javascript: poponload('/secure/mlu/Henderson.pdf')" class="linkw">Application</a>
    
    <a href="javascript: poponload('/secure/ucla/And.html')" class="linkw">Application</a>
    
    <a href="javascript: poponload('http://www.webdeveloper.com')" class="linkw">Application</a>
    
    </font></li>
    
    </body>
    </html>

  4. #4
    Join Date
    Feb 2008
    Posts
    1,666
    The error is probably in your moveTo line. Remove that line to find out.

  5. #5
    Join Date
    Jan 2008
    Location
    KnowledgeVille
    Posts
    36
    Thanks but the error tell me the line number which is ..
    <a href="javascript: poponload('http://www.google.com')" class="linkw">Application</a>

    When i added the single quotes and the url, i get the error. If i leave it blank the code works but opens a blank page

  6. #6
    Join Date
    Feb 2008
    Posts
    1,666
    Quote Originally Posted by AHendersonWebDe View Post
    Thanks but the error tell me the line number which is ..
    <a href="javascript: poponload('http://www.google.com')" class="linkw">Application</a>
    With single quotes is correct syntax. Are you using server-side code to build that HTML line? If so, then the problem is in the server-side which you are not showing. If not, then post a link to the full live page so I can try it out for myself.

  7. #7
    Join Date
    Jan 2008
    Location
    KnowledgeVille
    Posts
    36
    Code:
    <?php
     session_start();
    ?>
      
    
    
    
    <HTML>
    
    
    <head>
    <title>me</title>
    
    
    
    
    
    
    
    <style type="text/css">
    .linkw{color:#FFFFF;} 
    </style>
    
    
    
    </head>
    
    <SCRIPT language="JavaScript1.2">
    function poponload(url)
    {
    var testwindow= window.open ('', "mywindow","location=no,status=0,scrollbars=0,menubar=0,resizable=0,toolbar=0,directories=0,width=750,height=550");
    testwindow.moveTo(25,40);
    }
    </SCRIPT>
    
    
    <body style="background: #39275B; 
      background-attachment: fixed;
      background-repeat: no-repeat;  
      background-position: center;
    link="white" vlink="red" alink="white"">
    
    
     <?php
      
      // check session variable
    
      if (isset($_SESSION['valid_user']))
      {
        
            echo '<tr align="center" bgcolor="#39275B"><td colspan="3">';
    	echo '<a href="javascript: poponload(want to add url here)" class="linkw">Application</a>';
    	echo '</td></tr>';
         
            echo '<tr align="center" bgcolor="#39275B"><td colspan="3">';
    	echo '<a href="javascript: poponload(2nd url here)" class="linkw">Application</a>';
    	echo '</td></tr>';
        
       
            echo '<tr align="center" bgcolor="#39275B"><td colspan="3">';
    	echo '<a href="javascript: poponload(3rd url here)" class="linkw">Application</a>';
    	echo '</td></tr>';
        
        
            echo '<tr align="center" bgcolor="#39275B"><td colspan="3">';
    	echo '<a href="javascript: poponload(4th url here)" 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="login_me.php" class="linkw">Back to main page please</a>';
        
      }
    
      
    ?>
    
    
    </body>
    </html>


    Right now there is no url inside poponload()......and the code give a blank popup window. But when i add the url with single quotes poponload('/secure/me/me.pdf') or poponload(http://www.google.com) i receive a syntax error on this line stating that a "," or a ";" is missing

  8. #8
    Join Date
    Feb 2008
    Posts
    1,666
    Yep, the error was in your server-side code. Change this:
    Code:
    echo '<a href="javascript: poponload(want to add url here)" class="linkw">Application</a>';
    to this:
    Code:
    echo '<a href="javascript: poponload(\'want to add url here\')" class="linkw">Application</a>';

  9. #9
    Join Date
    Jan 2008
    Location
    KnowledgeVille
    Posts
    36
    Thanks, although it resolved the error, it now brings up a blank page...as if it totally ignores whats inside the parentheses

  10. #10
    Join Date
    Feb 2008
    Posts
    1,666
    So what does the generated HTML at the client look like now?

  11. #11
    Join Date
    Jan 2008
    Location
    KnowledgeVille
    Posts
    36
    I still receive a blank html page. I'm not sure what i'm missing yet i know i can been executed.

  12. #12
    Join Date
    Feb 2008
    Posts
    1,666
    No, the generated HTML *before* you click the link.

  13. #13
    Join Date
    Jan 2008
    Location
    KnowledgeVille
    Posts
    36
    Quote Originally Posted by MrNobody View Post
    No, the generated HTML *before* you click the link.
    I just created an html file (omitted the php file) with just the javascript function above and the issue still exist. i really dont think it has anything to do with the php coding because im still unable to insert a link and get the website. All your help is very appreciated. If i may ask you to create an html file with that javascript function and attempt to insert a link in the body of the file where u are calling the function and see if that website is executed. thanks again

  14. #14
    Join Date
    Feb 2008
    Posts
    1,666
    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);
    }

  15. #15
    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);
    }
    i have that in my code

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 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