Thursday, May 21, 2015

Highlight the anchor in HTML




To highlight the anchor use following css style code:

<style type="text/css" >
a{color:orange;text-decoration:none;font:bold} 
a:focus{color:cyan}
</style>
<script>
function FocusOnInput(){
        document.getElementById('text').focus();
}
//Add FocusOnInput() in onload event in the body attribute:
</script>

< body onload="FocusOnInput()" >

use id="text"   # highlighthe first componenet

Eg:
<a  id="text" href="http://google.com"> </a>


Note:  DOM Level 2 HTML
only elements that have a focus() method are 
HTMLInputElement, 
HTMLSelectElement, 
HTMLTextAreaElement and 
HTMLAnchorElement.       eg: <a  id='text' hreaf= ... >
And this notably omits HTMLButtonElement and HTMLAreaElement.

Logging on condition:
function logt(msg) 
{
  if(navigator.appName == "Netscape") {
    console.log("[DBG]: " + msg);
    }  else {
   alert(msg); }
}