Monday, February 6, 2012

Removing selection dotted borders around links that shows up on focus in Internet Explorer!

بسم الله الرحمن الرحيم
Dear all,
If you want to remove the selection dotted borders, that is made by Internet Explorer on links, that shows up when there is a focus on a link; when for example the user clicks on that link. You can add the following to your page. Absolutely, if you are using ASP.net, you will put this in the master page:
<script type="text/javascript" src=" http://code.jquery.com/jquery-1.7.1.js"></script>

<script language="javascript" type="text/javascript">
    jQuery(document).ready(function () {
        jQuery('a').focus(function () { jQuery(this).blur(); });
    });
</script>
The code will execute when the page finish loading, and will be applied on all ‘a’ tags. And, it will remove the focus on that tag immediately after focusing on it.
For more information about ready() function check: Tutorials: Introducing $(document).ready() at url: (http://docs.jquery.com/Tutorials:Introducing_$(document).ready()). And for more information about focus() function: http://api.jquery.com/focus/. Also, you can check http://api.jquery.com/blur/ for information about blur().
However, if you need to still apply this after Ajax calls! You will need to do as the following. In case, you are using ASP.Net and C#:
//Remove focus on links:
string scriptblock = "jQuery('a').focus(function(){jQuery(this).blur();});";
ScriptManager.RegisterClientScriptBlock(this.upLibraryEvents,
    typeof(UpdatePanel),
    "RemoveFocus", scriptblock, true);

You may ask: Why? Why caring about this? This is not even noticeable from normal user! And even if, the user noticed it, it does no harm!
The answer is that it is just to be used if the one, who is in somehow, responsible of quality assurance of your sites, tends to check the site not as a normal user!
Thanks to Alaa' Alkateeb.
Best Wishes,

Kindly support me by giving some good feedback, adding some useful comments, share it at Facebook and/or make a +1 for the article at Google from the bottom of the page.

________________________________
محمد الطباع (Muhammad Altabba)
SharePoint Developer with Project Management and Team Leadership Activities

No comments:

Post a Comment