#1
  1. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Mar 2002
    Location
    North West UK
    Posts
    119
    Rep Power
    13

    puting javascript into a <td> tag


    Hi
    I have managed (beginner with javascript) to get a table cell to be
    clickable by putting the following code inside the <td> tag
    onclick="location='executive.html'"; target="'mainwin'">
    However, it ignors the target bit and just loads in the open window. I want
    it to load into a window that has the name 'mainwin'. I can target this
    window when I use the target attribute in a html link, I guess the target
    attribute is not part of javascripts vocab, how to do it using javascript
    please?
    david
  2. #2
  3. No Profile Picture
    Contributing User
    Devshed Regular (2000 - 2499 posts)

    Join Date
    Jan 2003
    Location
    No es importante
    Posts
    2,065
    Rep Power
    14
    "Syntax open( URL, windowName[, windowFeatures])
    Parameters
    URL A string specifying the URL to open in the new window. See the
    Location object for a description of the URL components.
    windowName A string specifying the window name to use in the TARGET
    attribute of a FORM or A tag. windowName can contain only
    alphanumeric or underscore (_) characters.
    windowFeatures A string containing a comma-separated list determining whether or
    not to create various standard window features. These options are
    described in the following section."

    Source Javascript manaual.
    ...
    I hope this helps.
    El éxito consiste en una serie de pequeñas victorias día a día

    MySQL, MS SQL, MS ACCESS, Oracle Database Manager - http://victorpendleton.net/products/psdviewer.html
  4. #3
  5. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Mar 2002
    Location
    North West UK
    Posts
    119
    Rep Power
    13

    not a new window


    Hi
    Thanks for the help. The problem is, I don't want to create a new window. The onclick event is in a <td> tag, which is in a table, in a popup window. I want to be able to load the 'linked to' page back from the popup into the parent window, called 'mainwin'' which gave birth (I know that can't be the correct expression) to the popup window.
    hope I have described what I'm trying to do, please ask for further clarification if you need it.
    thanks
    david
  6. #4
  7. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Sep 2002
    Location
    san diego, ca
    Posts
    33
    Rep Power
    12
    Code:
    <td onclick="mainwin.location.href='executive.html';">
    Hope that helps.

    \* edited
    Last edited by MetalBlend; February 1st, 2003 at 06:23 PM.
  8. #5
  9. No Profile Picture
    Senior Citizen
    Devshed Regular (2000 - 2499 posts)

    Join Date
    Jan 2001
    Location
    leftcoast
    Posts
    2,019
    Rep Power
    16
    I guess the target attribute is not part of javascripts vocab...
    Well - the 'vocabulary' is often the same, it's the 'grammar' (syntax) that's completely different. Don't waste you time trying to 'translate' HTML into JS; the latter deserves serious study.

    Here:

    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
    <html>
    <head>
    <title>untitled</title>
    <script type="text/javascript" language="javascript">

    var popwin = null;

    function openit() {
    popwin = open('pop.htm','pop','status=0,width=200,height=234,left=200,top=200');
    if (popwin && !popwin.closed) popwin.focus();
    }

    </script>
    </head>
    <body>
    <a href="javascript&#58;void openit()">OPEN IT</a>
    </body>
    </html>

    [pop.htm]

    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
    <html>
    <head>
    <title>untitled</title>
    <style type="text/css">

    .linkedcell {
    cursor: hand;
    cursor: pointer;
    }

    </style>
    <script type="text/javascript" language="javascript">

    function setOpener(url) {
    if (opener && !opener.closed) opener.location = url;
    //self.close(); //closes this window
    //setTimeout('self.focus()',1000); //brings this window to front
    return false;
    }

    function setOpenerStatus(url) {
    if (opener && !opener.closed) opener.status = url;
    return true;
    }

    </script>
    </head>
    <body style="margin:0px;">
    <table cellpadding="0" cellspacing="0" border="1">
    <tr>
    <td class="linkedcell" width="200" height="200" bgcolor=green
    onmouseover="return setOpenerStatus('http://www.google.com')"
    onmouseout="return setOpenerStatus('')"
    onclick="return setOpener('http://www.google.com')"></td>
    </tr>
    </table>
    </body>
    </html>

    You can remove the commenting-out (//) from one line or the other (not both) in setOpener() to keep the pop-up window or destroy it. The mouseover status is a little extra. JavaScript refers to a 'parent' window as opener; frameset references have nothing to do with it. target is programmable via JS, but it's made to work with hrefs, not the case here.

    lol The word is 'spawn'....
  10. #6
  11. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Mar 2002
    Location
    North West UK
    Posts
    119
    Rep Power
    13

    wow ! - thanks


    Hi
    Thanks to all, especially Adios. The code looks good. The only trouble is I have already travelled quite far down my own road with code cobbled together from various sources. It all seems to work but now I'm wondering if I should scrap it and start again!

    I would be grateful if you could cast an eye over what I have already got - I'm sure it might have bugs etc in it that I'm not aware of - but , as I say, it seems to work.
    http://p0c79.phpwebhosting.com/


    The page which spawns (LOL) the popup is my home page - it has a square shaped graphic in the center of the page which is an imagemap and clicking on it gives rise to the popup


    and my stylesheet is

    [stylesheet.css]
    .titletr {
    width: 290px;
    font-weight: bold;
    font-size: 15px;
    font-family: Verdana,Arial,Helvetica,sans-serif;
    text-transform: uppercase;
    text-align: center;
    color: #663300;
    padding-bottom: 2px;
    margin-top: 10px;
    margin-bottom: 10px;
    border: 3px #663300 solid;
    background-color: #FFCC66;
    }

    P.legal {
    font-size: 8pt;
    font-weight: 200;
    font-family: Verdana,Arial,Helvetica,sans-serif;
    color: #663300;
    }

    UL LI {
    list-style-image: url(art/whitestar.gif);
    }

    td {
    line-height: 1.0;
    font-size: 13px;
    font-weight: bold;
    color: #663300;
    }

    .link {
    font-size: 8pt;
    }

    .navTable {
    border-top-width: 1px;
    border-right-width: 0px;
    border-bottom-width: 0px;
    border-left-width: 1px;
    border-top-style: solid;
    border-right-style: solid;
    border-bottom-style: solid;
    border-left-style: solid;
    border-top-color: #663300;
    border-right-color: #663300;
    border-bottom-color: #663300;
    border-left-color: #663300;
    }

    .navOver {
    font-family: Arial, Helvetica, sans-serif;
    border-bottom-width: 1px;
    border-bottom-style: solid;
    border-bottom-color: #663300;
    border-right-width: 1px;
    border-right-style: solid;
    border-right-color: #663300;
    cursor: pointer;
    }

    .navOut {
    font-family: Arial, Helvetica, sans-serif;
    border-bottom-width: 1px;
    border-bottom-style: solid;
    border-bottom-color: #663300;
    border-right-width: 1px;
    border-right-style: solid;
    border-right-color: #663300;
    }

    .navOverRow {
    background-color: #FFF0D9;
    }

    .navOutRow {
    background-color: #FFCC99;
    }

    .navOverRowb {
    background-color: #FAAB00;
    }

    .navOverRowc {
    background-color: #FFD697;
    }

    .navOverRowd {
    background-color: #DB7859;
    }

    a:link { color: #FFFFFF; text-decoration: none}
    a:visited { color: #F74902; text-decoration: none}
    a:hover { color: #F74902; text-decoration: none}


    If you waded through that lot I am very grateful. Sorry to ask so much. The website is under construction at
    http://p0c79.phpwebhosting.com/
  12. #7
  13. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Mar 2002
    Location
    North West UK
    Posts
    119
    Rep Power
    13

    popups source - forgot to include it


    I just thought, you can't see the source for the popup so here it is


    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
    <html>
    <head>
    <title>Business Page Menu</title>

    <script type="text/javascript" language="javascript">

    var focTimer = null;

    onblur = function() {
    if (focTimer == null) focTimer = setTimeout('self.focus()',200);
    }

    onfocus = function() {
    if (focTimer != null) {
    clearTimeout(focTimer);
    focTimer = null;
    }
    }

    onload = focus;

    </script>
    <link rel="stylesheet" href="stylesheet.css" type="text/css">
    </head>
    <body bgcolor="#FFD697">
    <table cellpadding="5" cellspacing="0" border="1" class="navTable">
    <tr class="navOutRow" onmouseover="this.className='navOverRowb'" onmouseout="this.className='navOutRow'">
    <td align="center" colspan="2" class="navOut" onmouseover="this.className='navOver'" onmouseout="this.className='navOut'" onclick="javascriptpener.parent.location.href='business.html'; setTimeout('self.close()',200)">
    <DIV class="titletr"><a href="business.html" target="mainwin"
    onClick="setTimeout('self.close()',200); return false">What is your business need?</a></DIV>
    </td>
    </tr>
    <tr class="navOutRow" onmouseover="this.className='navOverRowb'" onmouseout="this.className='navOutRow'">
    <td class="navOut" onmouseover="this.className='navOver'" onmouseout="this.className='navOut'"><a href="business.html" target="mainwin"
    onClick="setTimeout('self.close()',200)"><img src="art/whitestar.gif" border="0" width="31" height="31" align="middle"></a></td>
    <td class="navOut" onmouseover="this.className='navOver'" onmouseout="this.className='navOut'" onclick="javascriptpener.parent.location.href='business.html'; setTimeout('self.close()',200)"><a href="business.html" target="mainwin"
    onclick="setTimeout('self.close()',200); return false">You want to take time out to explore new ways of growing your business.</a></td>
    </tr>
    <tr class="navOutRow" onmouseover="this.className='navOverRowb'" onmouseout="this.className='navOutRow'">
    <td class="navOut" onmouseover="this.className='navOver'" onmouseout="this.className='navOut'"><a href="business.html" target="mainwin"
    onclick="setTimeout('self.close()',200)"><img src="art/whitestar.gif" border="0" width="31" height="31" align="middle"></a></td>
    <td class="navOut" onmouseover="this.className='navOver'" onmouseout="this.className='navOut' "onclick="javascriptpener.parent.location.href='business.html'; setTimeout('self.close()',200)"><a href="business.html" target="mainwin"
    onclick="setTimeout('self.close()',200); return false">You want a confidential sounding board for new business ideas, strategies and plans.</a></td>
    </tr>
    <tr class="navOutRow" onmouseover="this.className='navOverRowb'" onmouseout="this.className='navOutRow'">
    <td class="navOut" onmouseover="this.className='navOver'" onmouseout="this.className='navOut'"><a href="business.html" target="mainwin"
    onclick="setTimeout('self.close()',200)"><img src="art/whitestar.gif" border="0" width="31" height="31" align="middle"></a></td>
    <td class="navOut" onmouseover="this.className='navOver'" onmouseout="this.className='navOut' "onclick="javascriptpener.parent.location.href='business.html'; setTimeout('self.close()',200)"><a href="business.html" target="mainwin"
    onclick="setTimeout('self.close()',200); return false">You want support to ensure you exceed your business objectives.</a></td>
    </tr>
    <tr class="navOutRow" onmouseover="this.className='navOverRowb'" onmouseout="this.className='navOutRow'">
    <td class="navOut" onmouseover="this.className='navOver'" onmouseout="this.className='navOut'"><a href="business.html" target="mainwin"
    onclick="setTimeout('self.close()',200)"><img src="art/whitestar.gif" border="0" width="31" height="31" align="middle"></a></td>
    <td class="navOut" onmouseover="this.className='navOver'" onmouseout="this.className='navOut'" onclick="javascriptpener.parent.location.href='business.html'; setTimeout('self.close()',200)"><a href="business.html" target="mainwin"
    onclick="setTimeout('self.close()',200); return false">You want to take time out from operational issues to focuss on the development of the business.</a></td>
    </tr>
    <tr class="navOutRow" onmouseover="this.className='navOverRowb'" onmouseout="this.className='navOutRow'">
    <td class="navOut" onmouseover="this.className='navOver'" onmouseout="this.className='navOut'"><a href="business.html" target="mainwin"
    onclick="setTimeout('self.close()',200)"><img src="art/whitestar.gif" border="0" width="31" height="31" align="middle"></a></td>
    <td class="navOut" onmouseover="this.className='navOver'" onmouseout="this.className='navOut'" onclick="javascriptpener.parent.location.href='business.html'; setTimeout('self.close()',200)"><a href="business.html" target="mainwin"
    onclick="setTimeout('self.close()',200); return false">You need support whilst focusing on the operational efficiency of your business.</a></td>
    </tr>
    <tr class="navOutRow" onmouseover="this.className='navOverRowb'" onmouseout="this.className='navOutRow'">
    <td class="navOut" onmouseover="this.className='navOver'" onmouseout="this.className='navOut'"><a href="business.html" target="mainwin"
    onclick="setTimeout('self.close()',200)"><img src="art/whitestar.gif" border="0" width="31" height="31" align="middle"></a></td>
    <td class="navOut" onmouseover="this.className='navOver'" onmouseout="this.className='navOut'" onclick="javascriptpener.parent.location.href='business.html'; setTimeout('self.close()',200)"><a href="business.html" target="mainwin"
    onclick="setTimeout('self.close()',200); return false">You want objective guidance while you work through your staff recruitment, retention, development and motivation issues.</a></td>
    </tr>
    <tr class="navOutRow" onmouseover="this.className='navOverRowb'" onmouseout="this.className='navOutRow'">
    <td class="navOut" onmouseover="this.className='navOver'" onmouseout="this.className='navOut'"><a href="business.html" target="mainwin"
    onclick="setTimeout('self.close()',200)"><img src="art/whitestar.gif" border="0" width="31" height="31" align="middle"></a></td>
    <td class="navOut" onmouseover="this.className='navOver'" onmouseout="this.className='navOut'" onclick="javascriptpener.parent.location.href='business.html'; setTimeout('self.close()',200)"><a href="business.html" target="mainwin"
    onclick="setTimeout('self.close()',200); return false">You want an independent perspective whilst reviewing or redefining your sales and marketing strategies.</a></td>
    </tr>
    <tr class="navOutRow" onmouseover="this.className='navOverRowb'" onmouseout="this.className='navOutRow'">
    <td class="navOut" onmouseover="this.className='navOver'" onmouseout="this.className='navOut'"><a href="business.html" target="mainwin"
    onclick="setTimeout('self.close()',200)"><img src="art/whitestar.gif" border="0" width="31" height="31" align="middle"></a></td>
    <td class="navOut" onmouseover="this.className='navOver'" onmouseout="this.className='navOut'" onclick="javascriptpener.parent.location.href='business.html'; setTimeout('self.close()',200)"><a href="business.html" target="mainwin"
    onclick="setTimeout('self.close()',200); return false">You want an impartial view when taking time out to reappraise the financial aspects of your business.</a></td>
    </tr>
    <tr class="navOutRow" onmouseover="this.className='navOverRowb'" onmouseout="this.className='navOutRow'">
    <td class="navOut" onmouseover="this.className='navOver'" onmouseout="this.className='navOut'"><a href="business.html" target="mainwin"
    onclick="setTimeout('self.close()',200)"><img src="art/whitestar.gif" border="0" width="31" height="31" align="middle"></a></td>
    <td class="navOut" onmouseover="this.className='navOver'" onmouseout="this.className='navOut'" onclick="javascriptpener.parent.location.href='business.html'; setTimeout('self.close()',200)"><a href="business.html" target="mainwin"
    onclick="setTimeout('self.close()',200); return false">Other</a></td>
    </tr>
    <tr class="navOutRow" onmouseover="this.className='navOverRowb'" onmouseout="this.className='navOutRow'">
    <td colspan="2" align="center" class="navOut" onmouseover="this.className='navOver'" onmouseout="this.className='navOut'" onclick="javascript:window.close()"><a href="#" onclick="javascript:window.close()">close window</a></td>
    </tr>
    </table>
    </body>
    </html>

IMN logo majestic logo threadwatch logo seochat tools logo