SitePoint Sponsor

User Tag List

Results 1 to 8 of 8

Thread: open new window

  1. #1
    SitePoint Enthusiast
    Join Date
    Aug 2001
    Location
    Melbourne Australia
    Posts
    72
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    open new window

    I'm having problems with opening URLs in a new window. I don't know any Javascript and cobbled this together using Dreamweaver 4.

    The URL opens in a new window, but the original page then also goes to the new URL. I obviously want the original URL to stay where it is and the new URL to open in the new window.

    Any help would be greatly appreciated.

    Here's the script.


    This is in the head
    <script language="JavaScript">
    <!--
    function MM_openBrWindow(theURL,winName,features) { //v2.0
    window.open(theURL,winName,features);
    }
    //-->
    </script>



    This is in the body.


    echo "\t<td nowrap height=\"30\" colspan=\"3\" class=\"mmedia\"><a href=\"$web_address\" onClick=\"MM_openBrWindow('$web_address','NewspaperLink','toolbar=yes,location=yes,status=yes,menubar=yes,scrollbars=yes,resizable=yes,width=600,height=300')\">$web_address</a></td>\n";

    signature

  2. #2
    <C²: web standards /> cybercodeur's Avatar
    Join Date
    Dec 2001
    Location
    Montréal
    Posts
    729
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Is this stuff php? I believe echo is php...

    However, I think your problem comes from the fact that your a href tag has no target specified to it. Try putting traget="_blank" in your code as follows (or simply paste this in place of what you had before):

    echo "\t<td nowrap height=\"30\" colspan=\"3\" class=\"mmedia\"><a href=\"$web_address\" target="_blank" onClick=\"MM_openBrWindow('$web_address','NewspaperLink','toolbar=yes,location=yes,status=yes,menubar=yes,scrollbars=yes,resizable=yes,width=600,height=300')\">$web_address</a></td>\n";

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

  3. #3
    SitePoint Enthusiast
    Join Date
    Aug 2001
    Location
    Melbourne Australia
    Posts
    72
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Thanks for your help, Cybercodeur

    The language is PHP. Putting the target in works, but not quite.

    What happens now is that the target page, which is exactly the same size as the original page, loads. And also the target page loads in the dimensions that I have specified in the code.

    So what I have is three pages.

    - one original page.
    - one target page, same size as the original.
    - one target page, but in the dimensions that I specified.

    All I want is the original and the target page, with appropriate dimensions.


    Again, thanks for your help.
    signature

  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)
    Do you mean you have a page that loads back into another frame next to it? Like if your left menu (for example) got duplicated in your content zone?
    Denis Boudreau <C²/> - Web Standards & Accessibility
    [+] ICQ number: 115649885 || Email: denis@cybercodeur.net
    [+] Daily Weblog on Web standards and accessibility : CYBERcodeur.net

  5. #5
    You talkin to me? Anarchos's Avatar
    Join Date
    Oct 2000
    Location
    Austin, TX
    Posts
    1,438
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    You need to change <a href=\"$web_address\" to <a href=\"javascript:void(0)\"
    ck :: bringing chris to the masses.

  6. #6
    SitePoint Enthusiast
    Join Date
    Aug 2001
    Location
    Melbourne Australia
    Posts
    72
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Things are a little better but still not quite right. I have adopted your suggestion Anarchos and am getting a new window in the dimensions that I want.

    However, I am getting another window which is the same size as the original window. This has javascript:void(0) in the address line.

    Cybercodeur, I am not sure what you mean. I am not using frames. I am just getting two new windows instead of one, when I click on the URL.

    Here is the code that is output after the database query. It may reveal something.



    <!doctype html public "-//W3C//DTD HTML 4.0 Transitional//EN">
    <html>
    <head>
    <title>Media Search</title>
    <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
    <script language="JavaScript">
    <!--
    function MM_openBrWindow(theURL,winName,features) { //v2.0
    window.open(theURL,winName,features);
    }
    //-->
    </script>

    <link rel="stylesheet" href="file:///C|/MyMedia%20Database/Web%20Download/mmedia.css" type="text/css">
    </head>
    <body>
    <center>
    <h1><font face="Tahoma">MyMedia Search Results</font></h1>
    <form name="form1" method="post" action="">
    </form>
    <table bgcolor="#D0D0D0" border="6" cellpadding="4" cellspacing="4" >
    <tr>
    <td class="mmedia" width="68" height="-3" bgcolor="#CCCCCC"><b><strong>Outlet</strong></b></td>
    <td height="16" width="200" bgcolor="#CCCCCC" class="mmedia"><b>Address</b></td>
    <td nowrap height="16" width="107" class="mmedia"><b>Phone </b></td>
    <td nowrap height="16" width="108" class="mmedia"><b>Fax Number</b></td>
    </tr>
    <!-- Begin MySQL data presentation -->
    <tr>
    <td rowspan=2 width="68" height="35" bgcolor="#00CCFF" class="mmedia"><b>2BS</b></td>
    <td height="16" width="200" class="mmedia">PO Box 310 Bathurst NSW 2795</td>
    <td nowrap height="16" width="112" class="mmedia">(02) 6331 9403</td>
    <td nowrap height="16" width="108" class="mmedia"></td>
    </tr>
    <tr>
    <td height="30" colspan="2" class="mmedia"><a href="mailto:stereo@2bs.com.au">stereo@2bs.com.au</a></td>
    <td nowrap height="30" colspan="3" class="mmedia"><a href="javascript:void(0)" target="_blank" onClick="MM_openBrWindow('http://www.2bs.com.au','NewspaperLink','toolbar=yes,location=yes,status=yes,menubar=yes,scrollbars=yes,resizable=yes,width=600,height=300')">http://www.2bs.com.au</a></td>
    </tr>
    <tr bgcolor="#ffffff">
    <td colspan=6>&nbsp;<br></td>
    </tr>
    <tr>
    <td rowspan=2 width="68" height="35" bgcolor="#00CCFF" class="mmedia"><b>2MCE</b></td>
    <td height="16" width="200" class="mmedia">Panorama Avenue Bathurst NSW 2795</td>
    <td nowrap height="16" width="112" class="mmedia"></td>
    <td nowrap height="16" width="108" class="mmedia">(02) 6338 4010</td>
    </tr>
    <tr>
    <td height="30" colspan="2" class="mmedia"><a href="mailto:2mce@csu.edu.au">2mce@csu.edu.au</a></td>
    <td nowrap height="30" colspan="3" class="mmedia"><a href="javascript:void(0)" target="_blank" onClick="MM_openBrWindow('http://www.csu.edu.au/2MCE/','NewspaperLink','toolbar=yes,location=yes,status=yes,menubar=yes,scrollbars=yes,resizable=yes,width=600,height=300')">http://www.csu.edu.au/2MCE/</a></td>
    </tr>
    <tr bgcolor="#ffffff">
    <td colspan=6>&nbsp;<br></td>
    </tr>
    </table>
    <p>4 row(s) selected</p>
    <p><a href="index.html">Return to Start Page</a></p>

    </center>
    </body>
    </html>

    signature

  7. #7
    You talkin to me? Anarchos's Avatar
    Join Date
    Oct 2000
    Location
    Austin, TX
    Posts
    1,438
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Take out target="_blank" on the links.
    ck :: bringing chris to the masses.

  8. #8
    SitePoint Enthusiast
    Join Date
    Aug 2001
    Location
    Melbourne Australia
    Posts
    72
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Thanks, Anarchos.

    It worked well.
    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
  •