OnClick in Div only works when user clicks text

Discussion in 'Javascript' started by Daniel Beardsley, Mar 31, 2006.

  1. I have a div with some text in it and an onclick event. The onclick
    event only seems to fire when the user clicks the text.. not if they
    click the blank part of the div. This is in IE 6.

    The event is assigned in my JS.

    What gives?
    Daniel Beardsley, Mar 31, 2006
    #1
    1. Advertising

  2. Daniel  Beardsley

    Guest

    Daniel,

    I suggest that you post a small sample HTML file. I'd like to know
    what's in the "blank part of the div" -- do you mean nonbreaking
    spaces, ASCII codes, what? Once I see a sample, I should be able to
    help you.

    Stan Scott
    New York City
    , Apr 1, 2006
    #2
    1. Advertising

  3. Here is the HTML I'm using. It's pretty simple, clicking anywhere in
    the "Search" div should do an alert('hi') but it only works when I
    click on the text.

    I have IE 6.0.2900


    <!DOCTYPE html
    PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">

    <html>
    <head>
    <title>Untitled</title>
    <style type="text/css">
    <!--
    div
    {
    margin: 5px;
    }

    ..c1
    {
    clear:both;
    }

    ..c2
    {
    float:left;
    margin:10px;
    }

    ..pane
    {
    overflow:hidden;
    display:none;
    }

    #pane-left
    {
    width:300px;
    }

    #pane-right
    {
    width:800px;
    }

    ..sec-head
    {
    background-color: #FFEADA;
    border-top: 1px solid #999999;
    }

    -->
    </style>
    </head>
    <body>
    <div class="banner"><h1>Testing</h1></div>
    <div class="c1" style="overflow:auto;">
    <div class="c2" id="pane-left">
    <div class="sec-head" id="searchhead"
    onclick="alert('hi');">Search</div>
    <div class="pane" id="searchpane"><img alt="i"
    src="testlong.jpg"/></div>
    <div class="sec-head" id="mytrailshead" >My Stuff</div>
    <div class="pane" id="mypane"><img alt="i"
    src="testlong.jpg"/></div>
    <div class="sec-head" id="edithead">Editing</div>
    <div class="pane" id="editpane"><img alt="i"
    src="testlong.jpg"/></div>

    </div>
    <div class="c2" id="pane-right">
    <div class="sec-head" id="mainpane">
    <span>Stuff</span>
    <span style="text-align:right; width:50%;"><a
    id="link-hide">Hide</a></span>
    </div>
    <div class="c1"></div>
    <div class="sec-head" id="infopane">Info</div>
    <div class="c1"></div>
    </div>
    </div>
    </body>
    </html>


    wrote:
    > Daniel,
    >
    > I suggest that you post a small sample HTML file. I'd like to know
    > what's in the "blank part of the div" -- do you mean nonbreaking
    > spaces, ASCII codes, what? Once I see a sample, I should be able to
    > help you.
    >
    > Stan Scott
    > New York City
    Daniel Beardsley, Apr 2, 2006
    #3
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. meskaline
    Replies:
    0
    Views:
    935
    meskaline
    Nov 2, 2006
  2. PontiMax

    Clicks and double-clicks

    PontiMax, Jul 14, 2004, in forum: ASP .Net Datagrid Control
    Replies:
    2
    Views:
    177
    Eliyahu Goldin
    Jul 14, 2004
  3. irma
    Replies:
    0
    Views:
    103
  4. TnaG
    Replies:
    2
    Views:
    169
    Thomas 'PointedEars' Lahn
    Jul 18, 2004
  5. Steve

    onclick only works once

    Steve, Nov 20, 2008, in forum: Javascript
    Replies:
    18
    Views:
    616
    Timo Reitz
    Nov 23, 2008
Loading...

Share This Page