I have a chrome extension in which I have two text boxes, one for URL and other for LDAP. Whenever user clicks on extension icon, a popup page opens and I fill the URL text box with the current page URL with the help of following code:
function setValue()
{
var text = document.getElementById("url_textbox");
var ldap = document.getElementById("ldap_textbox");
chrome.tabs.getSelected(null, function(tab) {
text.value = tab.url;
ldap.focus();
});
}
The statement ldap.focus() is not working here. I am calling this function on page load.
<body onload = "setValue();">
What can I do for this?
Edit : This statement get the HTML element from the document whose Id is ldap_textbox.
var ldap = document.getElementById("ldap_textbox");