Please login or register.

Login with username, password and session length
Advanced search  

Author Topic: Invalid (x)html may cause unexpected javascript behaviour in Firefox  (Read 3183 times)

Joost

  • Guest

"Invalid (x)html may cause unexpected javascript behaviour in Firefox" :o
This may be obvious to all javascript gurus, but it is new to me (javascript newbie).

I did mix <div> elements with <label> elements in a way that's not valid in an article form (sNews). When clicking the strike button (inserts <del>), it also inserted <strong>.

Another strange behaviour occurred when I wrapped two input elements in a label element. This however, is valid xhtml. (html Tidy will not notice).
The click event applied to the button was applied to the text field as well.
Code: [Select]
<label>
<input type="button" onclick="dothis()" />
<input type="text" />
</label>

To 'undo' this behaviour, I had to wrap each input element separately.

Code: [Select]
<label>
<input type="button" onclick="dothis()" />
</label>
<label>
<input type="text" />
</label>

Just to let you know. ;)
« Last Edit: December 25, 2008, 05:32:41 AM by Joost »
Logged

funlw65

  • Hero Member
  • *****
  • Karma: 96
  • Posts: 771
    • Country Lab
Re: Invalid (x)html may cause unexpected javascript behaviour in Firefox
« Reply #1 on: December 23, 2008, 07:12:19 PM »

Thank you Joost!
Logged

Sven

  • ULTIMATE member
  • ******
  • Karma: 88
  • Posts: 2029
  • Chasing MY bugs!
    • hiseo.fr - rédacteur Web
Re: Invalid (x)html may cause unexpected javascript behaviour in Firefox
« Reply #2 on: December 24, 2008, 10:02:31 AM »

That's very interesting!