SitePoint Sponsor

User Tag List

Results 1 to 12 of 12
  1. #1
    SitePoint Wizard silver trophy TheOriginalH's Avatar
    Join Date
    Aug 2000
    Location
    Thailand
    Posts
    4,810
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)

    Opening resized windows

    I have the following JavaScript for opening a re-sized window:

    <script type="text/javascript">
    <!--
    window.open ('showdis.php?icid=', 'newwindow', config='height=150,
    width=75, toolbar=no, menubar=no, scrollbars=no, resizable=no,
    location=no, directories=no, status=no')
    -->
    </script>

    However, I have multiple icons that I'd like to open a window of specified size, each with the same url but a unique "icid" (php obviously).

    The script doesn't accomodate for mulitple destinations - any idea how to sort it?
    ~The Artist Latterly Known as Crazy Hamster~
    922ee590a26bd62eb9b33cf2877a00df
    Currently delving into Django, GIT & CentOS

  2. #2
    SitePoint Wizard silver trophy Jeremy W.'s Avatar
    Join Date
    Jun 2001
    Location
    Toronto, Canada
    Posts
    9,121
    Mentioned
    2 Post(s)
    Tagged
    0 Thread(s)

    Re: Opening resized windows

    Code:
    <script type="text/javascript">
    <!--
    function winOpen(loc)
    {
    window.open ('showdis.php?icid=' + loc, 'newwindow', config='height=150,
    width=75, toolbar=no, menubar=no, scrollbars=no, resizable=no,
    location=no, directories=no, status=no');
    }
    // -->
    </script>
    You can call the above by saying: winOpen(1231)

    Is that what you want?
    SVP Marketing, SoCast SRM
    Personal blog: Strategerize
    Twitter: @jeremywright

  3. #3
    SitePoint Zealot
    Join Date
    Aug 2001
    Location
    DC
    Posts
    113
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Hell, take a step further . .. .

    /*------------------------------------------------------------------
    FUNCTION: Opens a new window
    RECEIVES:
    string url - url for new window
    string name - reference name of new window
    string widgets - window features to display (e.g. toolbar,etc.)
    RETURNS: string
    ------------------------------------------------------------------*/
    function openWindow (url,name,widgets)
    {
    popupWin = window.open (url,name,widgets);
    popupWin.focus();
    }

    example calling it . . .

    <a href="javascriptpenWindow('urlGoesHere','newWindow','height=450,width=550,scrollbars=yes,toolbar=no,location=no');">open window</a>
    signature

  4. #4
    SitePoint Wizard silver trophy TheOriginalH's Avatar
    Join Date
    Aug 2000
    Location
    Thailand
    Posts
    4,810
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)
    hmmm, thanks guys. I've used J's solution since it uses less code, but she no wanna play? Could anyone take a look - it may be an Opera thing (js is on though), I don't have a pc with IE on it at the mo.

    (the icons on the left are the case in point..)

    http://www.meetinthemiddle.co.uk/dev...n.php?locid=12
    ~The Artist Latterly Known as Crazy Hamster~
    922ee590a26bd62eb9b33cf2877a00df
    Currently delving into Django, GIT & CentOS

  5. #5
    SitePoint Wizard silver trophy Jeremy W.'s Avatar
    Join Date
    Jun 2001
    Location
    Toronto, Canada
    Posts
    9,121
    Mentioned
    2 Post(s)
    Tagged
    0 Thread(s)
    I always use www.studiococo.com/custom.asp?window.asp, it's easier then remember the code myself

    edit: and I get an error on your page H.
    SVP Marketing, SoCast SRM
    Personal blog: Strategerize
    Twitter: @jeremywright

  6. #6
    SitePoint Wizard silver trophy TheOriginalH's Avatar
    Join Date
    Aug 2000
    Location
    Thailand
    Posts
    4,810
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)
    Could you tell me what line it's on J? - no report in Opera...
    ~The Artist Latterly Known as Crazy Hamster~
    922ee590a26bd62eb9b33cf2877a00df
    Currently delving into Django, GIT & CentOS

  7. #7
    SitePoint Wizard silver trophy Jeremy W.'s Avatar
    Join Date
    Jun 2001
    Location
    Toronto, Canada
    Posts
    9,121
    Mentioned
    2 Post(s)
    Tagged
    0 Thread(s)
    Doesn't say, just says "object expected"... Useless IE errors, eh?
    SVP Marketing, SoCast SRM
    Personal blog: Strategerize
    Twitter: @jeremywright

  8. #8
    SitePoint Wizard silver trophy TheOriginalH's Avatar
    Join Date
    Aug 2000
    Location
    Thailand
    Posts
    4,810
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)
    bugger, they're as bad as each other ah well, time to call it a night anyway really.
    ~The Artist Latterly Known as Crazy Hamster~
    922ee590a26bd62eb9b33cf2877a00df
    Currently delving into Django, GIT & CentOS

  9. #9
    SitePoint Wizard silver trophy TheOriginalH's Avatar
    Join Date
    Aug 2000
    Location
    Thailand
    Posts
    4,810
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)
    No, no sleep until I've cracked it....

    I've tried 2 methods:

    function dwinOpen(loc)
    {
    window.open('showdis.php?icid='+ loc, 'newwindow', config='height=150,
    width=75, toolbar=no, menubar=no, scrollbars=no, resizable=no, location=no, directories=no, status=no');
    }

    and

    function lwinOpen(loc)
    {
    window.open("showleis.php?icid="+ loc, "newwindow", "toolbar=no,scrollbars=no,resizable=no,width=75,height=150");
    }


    ...both produce errors - any idea what I've done wrong?
    ~The Artist Latterly Known as Crazy Hamster~
    922ee590a26bd62eb9b33cf2877a00df
    Currently delving into Django, GIT & CentOS

  10. #10
    SitePoint Wizard silver trophy Jeremy W.'s Avatar
    Join Date
    Jun 2001
    Location
    Toronto, Canada
    Posts
    9,121
    Mentioned
    2 Post(s)
    Tagged
    0 Thread(s)
    Well, first off, in your code, your JS line spans 2 lines... bad boy

    Have you tried executing any JS, ignore the window.open() bit?

    strike the above... while rewriting your JS your site started working...
    SVP Marketing, SoCast SRM
    Personal blog: Strategerize
    Twitter: @jeremywright

  11. #11
    SitePoint Wizard silver trophy TheOriginalH's Avatar
    Join Date
    Aug 2000
    Location
    Thailand
    Posts
    4,810
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)
    Yep, tried again using the second code suggestion - means more code per link - if it was the line spanning causing the error I'll revisit the original method, At least it's working now - can sleep soundly

    ..except have discovered that the cdata stuff produces an error in ie4 (hey, it was the only disc I could find)
    ~The Artist Latterly Known as Crazy Hamster~
    922ee590a26bd62eb9b33cf2877a00df
    Currently delving into Django, GIT & CentOS

  12. #12
    SitePoint Zealot
    Join Date
    Aug 2001
    Location
    DC
    Posts
    113
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Originally posted by TheOriginalH
    No, no sleep until I've cracked it....

    I've tried 2 methods:

    function dwinOpen(loc)
    {
    window.open('showdis.php?icid='+ loc, 'newwindow', config='height=150,
    width=75, toolbar=no, menubar=no, scrollbars=no, resizable=no, location=no, directories=no, status=no');
    }

    and

    function lwinOpen(loc)
    {
    window.open("showleis.php?icid="+ loc, "newwindow", "toolbar=no,scrollbars=no,resizable=no,width=75,height=150");
    }


    ...both produce errors - any idea what I've done wrong?
    If you called the scripts above like . . .

    <a href="javascript:dwinOpen('1');">a</a>

    . . . then that should have worked where "1" is the loc value. Weird. YOU DEFINITELY needed to have the parameters of the function on one complete line.

    Glad the other function worked. It is actually more flexible allowing you to also set the window name and values.
    signature


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
  •