• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

upgrading to html 5: javascript inline (not internal, but inline, e.g. inside onclick)

 
Jesus Angeles
Ranch Hand
Posts: 2068
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

I understand that, for external, and internal, we remove some attributes like those that specify javascript, like below:


How about for inline javascript?

Do we need to remove those "javascript:" prefixes?

-------------
Example:



-------------
Example:



-------------

Are there any rule on this? Should we remove the "javascript:" on all of them? Or just leave them alone there?
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 65123
91
IntelliJ IDE Java jQuery Mac Mac OS X
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
For the href the "javascript:" prefix is a pseudo-protocol to distinguish it from other protocols such as http:. On attributes such as onclick, its useless and shouldn't be specified.

Of course, if you're using Unobtrusive JavaScript, you aren't mixing script in with the structure and don't use attributes such as onclick at all.
 
Jaikiran Pai
Marshal
Pie
Posts: 10447
227
IntelliJ IDE Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Bear Bibeault wrote:
Of course, if you're using Unobtrusive JavaScript, you aren't mixing script in with the structure and don't use attributes such as onclick at all.


That's new to me and just did a quick search on it and it does make sense. Learnt something new
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 65123
91
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
In the same way that CSS removes style form the structure, Unobtrusive JavaScript removes behavior from the structure. This makes for good Separation of Concerns between style, behavior and structure.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic