SitePoint Sponsor

User Tag List

Results 1 to 8 of 8

Hybrid View

  1. #1
    SitePoint Member
    Join Date
    Apr 2002
    Posts
    9
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Functions & window popup

    I have a number of windows that i want to open up in a seperate window, and i have tried the following code

    <script language="javascript">
    //<!--
    function popup(a url)
    { window.open ("a url","Comments","width=500,height=400,location=0,menubar=0,resizable=1,scrollbars=1,status=0,titlebar=1,toolbar=0") }
    //-->
    </script>

    with the link being <a href="javascript:popup(example.html)">

    as you can see, Im a complete newbie to JavaScript

    when i click on the link, nothing pops up and nothing happens. there is the little error on page status bar message, so i guess its something to do with my code....
    Last edited by gio; Aug 21, 2002 at 07:50.

  2. #2
    Drupaler bronze trophy greg.harvey's Avatar
    Join Date
    Jul 2002
    Location
    London, UK
    Posts
    3,258
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    The problem probably lies with a url. Try it with just url.

    G

  3. #3
    SitePoint Member
    Join Date
    Apr 2002
    Posts
    9
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    hmmm, well ive changed it now.

    I use it in a poll script, and this is the exact code that i have written.

    <script language="javascript">
    //<!--
    function popup(url)
    { window.open ("url","Comments","width=500,height=400,location=1,menubar=0,resizable=1,scrollbars=1,status=0,titlebar=1,toolbar=0") }
    //-->
    </script>

    and the link is

    <a href="javascript:popup('[%scriptname%]?poll=[%pollid%]&viewcomments=1')">Comments</a>

    the script name and pollid are variables in the poll. When i click on the popup, i get a window with the url http://thegaffer.neopages.net/url instead of http://thegaffer.neopages.net/[%scriptname%]?poll=[%pollid%]&viewcomments=1 with the variables obviuosly replaced with their values

    whats wrong? u can try for yourself at http://thegaffer.neopages.net/index2.shtml, and click on the Poll comments.
    Last edited by gio; Aug 21, 2002 at 09:14.

  4. #4
    Drupaler bronze trophy greg.harvey's Avatar
    Join Date
    Jul 2002
    Location
    London, UK
    Posts
    3,258
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Whoops! Ignore that ... interesting.

    G
    Last edited by greg.harvey; Aug 21, 2002 at 09:20.

  5. #5
    SitePoint Member
    Join Date
    Apr 2002
    Posts
    9
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    whats wrong is that instead of taking the value of "url" it just puts the text url in the url...

    eg thegaffer.neopages.net/url
    instead of (and lets say url=test.html)
    thegaffer.neopages.net/test.html

  6. #6
    Drupaler bronze trophy greg.harvey's Avatar
    Join Date
    Jul 2002
    Location
    London, UK
    Posts
    3,258
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    The JavaScript isn't at fault. The server-side stuff is returning the URL /cgi-bin/poll/poll.cgi?poll=000003&viewcomments=1 whereas it should be (and I checked) cgi-bin/poll/poll.cgi?poll=000003&viewcomments=1. The problem is that the Perl, [%scriptname%], is giving you an unwanted forward slash at the start of your URL. May I suggest that you throw this part in manually since it won't change, ie:

    <a href="javascript: popup('cgi-bin/poll/poll.cgi?poll=[%pollid%]&viewcomments=1')">Comments</a>


  7. #7
    SitePoint Member
    Join Date
    Apr 2002
    Posts
    9
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    nope still doesnt work

  8. #8
    Drupaler bronze trophy greg.harvey's Avatar
    Join Date
    Jul 2002
    Location
    London, UK
    Posts
    3,258
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Well manually typing in that URL worked ....



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
  •