OnClick in Div only works when user clicks text

D

Daniel Beardsley

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?
 
S

stannyc

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
 
D

Daniel Beardsley

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>
 

Ask a Question

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

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,581
Members
45,056
Latest member
GlycogenSupporthealth

Latest Threads

Top