Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.javascript > #26839

Re: FireFox onclick problem

From Joao Rodrigues <groups_jr-1@yahoo.com.br>
Newsgroups comp.lang.javascript
Subject Re: FireFox onclick problem
Date 2015-02-10 19:34 -0200
Organization Aioe.org NNTP Server
Message-ID <mbdthm$fk0$1@speranza.aioe.org> (permalink)
References <cjuvd1F7thrU1@mid.individual.net>

Show all headers | View raw


Mel Smith wrote:
> Hi:
> 
> 
>     IE and Chrome both 'hide' the <div> below when a user 'clicks' on the 
> button.
> 
>     However, an automatically updated version of FF does NOT .
> 
>     That is, when a user 'clicks' on the 'Hide Me' button, nothing happens. 
> Very few (any ??) of my users have FF installed, and I very seldom use FF. 
> But month ago, I *believe* it worked correctly -- but I'm not sure.
> 
> Question:
> 
>     What FF setting could I have (somehow) set wrongly such that 'onclicks' 
> were not acted on.

I regularly work with FF and Firebug. And I've tested your example
successfully. So firstly I'd suggest validating you markup [1]. Also try
to debug your script with Firebug [2] and / or with the new Developer
Tools available in the latest FF version.

[1] http://validator.w3.org/
[2] http://getfirebug.com/

> 
> TIA for any hints. Again, IE and Chrome work correctly
> 
> -Mel Smith
> 
> **** my html and ES/JS code below ******
>    <div id="inotice">
>    <input type="button" onclick="hidenotice();" value="Hide Me" />
>     <!-- lots of text and <br> here -->
>    </div>
> 
> function hidenotice() {
> var el=document.getElementById("inotice");
> el.style.display="none";
> }
> 

Also you can use a div styled as a button, instead of the button
element, and use event delegation to hide the parent div. E.g.

<style>
  .button {
   border-radius:4px;
   background-color: #f2f5f7;
   border: 1px outset #ccc;
   color: #000;
   cursor: pointer;
   font-weight: 900;
   text-align: center;
   width: 150px;
  }
</style>

<div id="inotice">
  <div class="button">Hide Me</div>
  <p>Lots of text going here</p>
</div>

<script type="text/javascript">
  function hideDiv(e) {
    if (e.target.firstChild.nodeValue == "Hide Me") {
      e.currentTarget.style.display = 'none';
    }
  }

  document.getElementById('inotice').
    addEventListener('click', hideDiv, false);
</script>


-- 
Joao Rodrigues

Back to comp.lang.javascript | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread


Thread

FireFox onclick problem "Mel Smith" <syntel@cox.net> - 2015-02-10 11:02 -0700
  Re: FireFox onclick problem "Evertjan." <exxjxw.hannivoort@inter.nl.net> - 2015-02-10 20:32 +0100
    Re: FireFox onclick problem "Mel Smith" <syntel@cox.net> - 2015-02-10 14:55 -0700
  Re: FireFox onclick problem Joao Rodrigues <groups_jr-1@yahoo.com.br> - 2015-02-10 19:34 -0200
    Re: FireFox onclick problem "Mel Smith" <syntel@cox.net> - 2015-02-10 15:21 -0700
  Re: FireFox onclick problem "Christoph M. Becker" <cmbecker69@arcor.de> - 2015-02-10 23:37 +0100
    Re: FireFox onclick problem "Mel Smith" <syntel@cox.net> - 2015-02-10 16:21 -0700

csiph-web