SitePoint Sponsor

User Tag List

Results 1 to 6 of 6
  1. #1
    Bruno Delepierre
    SitePoint Community Guest

    open link in new window

    Any Javascript wizard can help me with this one? I'd like to open links on my site that point to other sites using javascript. I'd also would like to have them opened in a new window. Can anybody tell me how to do this?

    Thanks

  2. #2
    Currently Occupied; Till Sunda Andrew-J2000's Avatar
    Join Date
    Aug 2001
    Location
    London
    Posts
    2,475
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    :)

    This what you after

    <script>
    function popitup(url,winname,width,height,tools)
    {
    window.open(url, winname, 'width=' + width + ', height=' + height + '\',' + tools + '\'');
    }
    //call it by
    //popitup("http://www.msn.com","num",500,500,null)
    </script>

    <a href="javascript:void(0)" onclick='popitup("http://www.msn.com","num",500,500,null)' onmouseover="window.status='Click Me'; return true">popit</a>

  3. #3
    Non-Member mmi's Avatar
    Join Date
    Jun 2001
    Location
    Rhode Island
    Posts
    587
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    hey Bruno - here's a sample from mmy site:

    function openCommonWindow() {
    commonWindow=window.open('http://www.tompaine.com/','commonWin','location=yes,toolbar=yes,menubar=yes,status=yes,scrollbars=yes,resizable=yes,width=770,height=420,screenX=20,screenY=20,left=20,top=20');}
    and then:
    <a HREF="javascript: openCommonWindow()">Common Sense</a>
    post back if you have any Q's about attributes or whatever, although any js tutorial should contain this stuff

    edit: as you can see, more than one way t'skin this cat

    I don't think you should have that second line break in mmy code - I think the page is doing that (not anymore ) - now, it's there again
    Last edited by mmi; Feb 20, 2002 at 11:42.

  4. #4
    <C²: web standards /> cybercodeur's Avatar
    Join Date
    Dec 2001
    Location
    Montréal
    Posts
    729
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    [Transcripted from another thread I wrote a while back...]

    ...The trick would be to use javascript to create a new window with set dimensions. You can even create one with specific parameters passed along. Let me suggest you this script of mine which works like a charm. The window so created will even be centered in your screen, which is something i myself like a lot. Hope you enjoy it too.

    <a href="Javascript:NewWindow('http://www.webmasterbase.com','WebmasterBase','775','550','0','0','0','0','0','0','0');">Link</a>

    Just paste this cute little function in the head of your page or in an external js page.

    <unction NewWindow(page,nom,w,h,t,l,d,s,m,sc,r)
    {
    var newleft = (screen.width - w) / 2;
    var newtop = (screen.height - h) / 2;
    var prop1="toolbar=" + t + ",location=" + l + ",directories=" + d + ",status=" + s + ",menubar=" + m + ",scrollbars=" + sc + ",resizable=" + r +","
    var prop2="width=" + w + ",height=" + h + ",top=" + newtop + ",left=" + newleft
    window.open(page,nom,prop1+prop2);



    Enjoy!!!
    Denis Boudreau <C²/> - Web Standards & Accessibility
    [+] ICQ number: 115649885 || Email: denis@cybercodeur.net
    [+] Daily Weblog on Web standards and accessibility : CYBERcodeur.net

  5. #5
    Currently Occupied; Till Sunda Andrew-J2000's Avatar
    Join Date
    Aug 2001
    Location
    London
    Posts
    2,475
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Nice;)

    Works well.

  6. #6
    <C²: web standards /> cybercodeur's Avatar
    Join Date
    Dec 2001
    Location
    Montréal
    Posts
    729
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Red face aaaahhhh thank you

    Denis Boudreau <C²/> - Web Standards & Accessibility
    [+] ICQ number: 115649885 || Email: denis@cybercodeur.net
    [+] Daily Weblog on Web standards and accessibility : CYBERcodeur.net


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
  •