I am setting a url to a DOM of a website. Now I could done it by copying the actual url, as below:
document.getElementById('mediaWebUrl').setAttribute('value','https://www.youtube.com/watch?v=hkOTAmmuv_4');
It is not convenient enough. I want to substitute the actual url with a variable. like below:
chrome.tabs.query({active: true, currentWindow: true}, function(tabs) {
var activeTab = tabs[0];
var videoUrl = activeTab.url; // or do whatever you need
});
But when I do the job as below:
document.getElementById('mediaWebUrl').setAttribute('value',videoUrl);
it didn't succeed and nothing happened. Why? I confirmed the type of the variable "videoUrl" is a string using alert(typeof videoUrl). As neophyte in Javascript, I really need advice in this simple question. Thank you.