SitePoint Sponsor

User Tag List

Results 1 to 3 of 3
  1. #1
    SitePoint Zealot
    Join Date
    Aug 2005
    Posts
    166
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Javascript question for pop-up windows...

    Okay, I know absolutely nothing about Javascript. I've tried looking up a solution for this problem but I can't find one. I'm using these two sections of code to create a pop-up window for a submission form on my site:
    PHP Code:
    javascript:load() 
    and...
    PHP Code:
    <script Language="JavaScript">
    function load() {
    var load = window.open('http://www.mysite.com/mailtofriend.php?url=<? echo $url?>','','scrollbars=no,menubar=no,height=300,width=400,resizable=no,toolbar=no,location=no,status=no');
    }
    // -->
    </script>
    Now, my dilemma is that I need to create another pop-up like the one above but I don't know how. In other words, I guess I need something like this:
    PHP Code:
    javascript:load2() 
    and...
    PHP Code:
    <script Language="JavaScript">
    function load() {
    var load2 = window.open('http://www.mysite.com/mailtofriend.php?url=<? echo $url?>','','scrollbars=no,menubar=no,height=300,width=400,resizable=no,toolbar=no,location=no,status=no');
    }
    // -->
    </script>
    See how little I know . Can someone help me?

    Thank you...

  2. #2
    SitePoint Wizard
    Join Date
    Mar 2001
    Posts
    3,537
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    First, don't use "javascript:". It doesn't do anything in this case, and it's use is very limited. When you see javascript code with "javascript:" sprinkled about, you can be pretty sure that whoever wrote the script didn't know what they were doing.

    One of the first principles of any language is NOT to use the same names for things in your program, which is what you are doing here:

    Code:
    function load() {
    var load = .....
    If you can't think up 10 different names, then you shouldn't be allowed anywhere near a computer.

    Do you know what a function is? If so rewrite the load() funtion to take one parameter: the url, e.g.:

    Code:
    function load(myURL)
    {
    
    }
    Inside the load() function you will call window.open(), which is of this form:

    Code:
    window.open(myURL, '', 'scrollbars=no,menubar=no,height=300,width=400,resizable=no,toolbar=no,location=no,status=no');
    Then, to open up a second popup window just call the function again with the page you want:

    load("http://somepage.htm");

  3. #3
    SitePoint Evangelist nsj's Avatar
    Join Date
    Oct 2005
    Location
    Jamaica (W.I)
    Posts
    447
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    If you want to load a new window passing parameters based on a form submission,
    http://www.sitepoint.com/forums/showthread.php?t=309849
    (Post 2).


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
  •