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

"

"

X vBulletin 4.2.2 Debug Information

  • Page Generation 0.13920 seconds
  • Memory Usage 3,017KB
  • Queries Executed 15 (?)
More Information
Template Usage (37):
  • (1)SHOWTHREAD
  • (1)ad_footer_end
  • (1)ad_footer_start
  • (1)ad_global_above_footer
  • (1)ad_global_below_navbar
  • (1)ad_global_header1
  • (1)ad_global_header2
  • (1)ad_navbar_below
  • (1)ad_showthread_firstpost_sig
  • (1)ad_showthread_firstpost_start
  • (1)ad_thread_first_post_content
  • (1)ad_thread_last_post_content
  • (9)bbcode_code
  • (3)bbcode_quote
  • (1)footer
  • (1)forumjump
  • (1)forumrules
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (1)headinclude_bottom
  • (15)memberaction_dropdown
  • (1)navbar
  • (4)navbar_link
  • (1)navbar_moderation
  • (1)navbar_noticebit
  • (1)navbar_tabs
  • (2)option
  • (1)pagenav
  • (1)pagenav_curpage
  • (1)pagenav_pagelink
  • (15)postbit
  • (15)postbit_onlinestatus
  • (15)postbit_wrapper
  • (1)spacer_close
  • (1)spacer_open
  • (1)tagbit_wrapper 

Phrase Groups Available (6):
  • global
  • inlinemod
  • postbit
  • posting
  • reputationlevel
  • showthread
Included Files (26):
  • ./showthread.php
  • ./global.php
  • ./includes/class_bootstrap.php
  • ./includes/init.php
  • ./includes/class_core.php
  • ./includes/config.php
  • ./includes/functions.php
  • ./includes/functions_navigation.php
  • ./includes/class_friendly_url.php
  • ./includes/class_hook.php
  • ./includes/class_bootstrap_framework.php
  • ./vb/vb.php
  • ./vb/phrase.php
  • ./includes/functions_facebook.php
  • ./includes/functions_calendar.php
  • ./includes/functions_bigthree.php
  • ./includes/class_postbit.php
  • ./includes/class_bbcode.php
  • ./includes/functions_reputation.php
  • ./includes/functions_notice.php
  • ./packages/vbattach/attach.php
  • ./vb/types.php
  • ./vb/cache.php
  • ./vb/cache/db.php
  • ./vb/cache/observer/db.php
  • ./vb/cache/observer.php 

Hooks Called (75):
  • init_startup
  • friendlyurl_resolve_class
  • init_startup_session_setup_start
  • database_pre_fetch_array
  • database_post_fetch_array
  • init_startup_session_setup_complete
  • global_bootstrap_init_start
  • global_bootstrap_init_complete
  • cache_permissions
  • fetch_postinfo_query
  • fetch_postinfo
  • fetch_threadinfo_query
  • fetch_threadinfo
  • fetch_foruminfo
  • load_show_variables
  • load_forum_show_variables
  • global_state_check
  • global_bootstrap_complete
  • global_start
  • style_fetch
  • global_setup_complete
  • showthread_start
  • showthread_getinfo
  • strip_bbcode
  • friendlyurl_clean_fragment
  • friendlyurl_geturl
  • forumjump
  • cache_templates
  • cache_templates_process
  • template_register_var
  • template_render_output
  • fetch_template_start
  • fetch_template_complete
  • parse_templates
  • fetch_musername
  • notices_check_start
  • notices_noticebit
  • process_templates_complete
  • friendlyurl_redirect_canonical
  • showthread_post_start
  • showthread_query_postids
  • showthread_query
  • bbcode_fetch_tags
  • bbcode_create
  • showthread_postbit_create
  • postbit_factory
  • postbit_display_start
  • postbit_imicons
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • postbit_display_complete
  • memberaction_dropdown
  • pagenav_page
  • pagenav_complete
  • tag_fetchbit
  • tag_fetchbit_complete
  • forumrules
  • navbits
  • navbits_complete
  • build_navigation_data
  • build_navigation_array
  • check_navigation_permission
  • process_navigation_links_start
  • process_navigation_links_complete
  • set_navigation_menu_element
  • build_navigation_menudata
  • build_navigation_listdata
  • build_navigation_list
  • set_navigation_tab_main
  • set_navigation_tab_fallback
  • navigation_tab_complete
  • fb_like_button
  • showthread_complete
  • page_templates