Friday, February 15, 2013

Why Do We Have To Make Things So Complex?

Many times, things in life are complex on their own and there is no other way.  Sometimes there are things that can be simple but we make them over complex.  Case in point this article that explains Make An Entire Div Clickable

Proposed Solution:



$(".myBox").click(function(){
     window.location=$(this).find("a").attr("href"); 
     return false;
});
Looks for a link inside div with class of "myBox". Redirects to that links value when anywhere in div is clicked.
Reference HTML:
<div class="myBox">
     blah blah blah.
    <a href="http://google.com">link</a>
</div>

Simpler Solution:

<div onclick="location.href='#';" style="cursor: pointer;">
</div>

Reason For Complexity:

1) Browsers do not follow standards.  divs cannot be clickable in Internet Explorer.
2) What if the user has javascript turned off?  You may still want the link to work.



How Can We Simplify:

1) We should actively work towards making browsers work as they should.  HTML5 is supposed to do this but already there are differences in implementation.  If we work together we can make things simpler.


If you have any tips or tricks to make anything less complex or less complicated or have an explanation on why things are complicated please email them to me at chrisw_88@outlook.com and we will post them here.

No comments:

Post a Comment