Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Javascript > OnClick in Div only works when user clicks text

Reply
Thread Tools

OnClick in Div only works when user clicks text

 
 
Daniel Beardsley
Guest
Posts: n/a
 
      03-31-2006
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?

 
Reply With Quote
 
 
 
 
stannyc@gmail.com
Guest
Posts: n/a
 
      04-01-2006
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

 
Reply With Quote
 
 
 
 
Daniel Beardsley
Guest
Posts: n/a
 
      04-02-2006
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>


http://www.velocityreviews.com/forums/(E-Mail Removed) 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


 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
<div ... /> and <div ...></div> K Viltersten ASP .Net 4 03-31-2009 07:33 PM
NS/FF don't change div offsetWidth when div innerHTML is added toand div becomes wider mscir Javascript 3 06-26-2005 04:04 PM
Q: Div A inside Div B is larger than Div B Dwayne Madsen Javascript 1 06-01-2005 03:02 PM
Clicks and double-clicks PontiMax ASP .Net Datagrid Control 2 07-14-2004 11:00 AM
how to change anchor text color when user clicks on it irma Javascript 0 09-29-2003 04:50 PM



Advertisments