Suppose I have a jsp page that holds session data like this,
<input type="hidden" id="sessionData" value="${login}"/>
Now, I have a chrome extension and inside the js file (e.g., "popup.js") I want to access the data using getElementById
. For example,
chrome.tabs.getSelected(null,function(tab) {
//alert(tab.id);
var sessionData = document.getElementById('sessionData').value;
console.log('session data is '+sessionData);
alert(sessionData.lang);
});
Unfortunately, I can't fetch any session data. No alert is showing. Before fetching session data, alert(tab.id);
shows the tab id correctly. (Please don't suggest that chrome.tabs.getSelected
is deprecated; I already know that.)