I don't know what you are doing but the reason for the error is that you are creating and using an instance of Youtube
constructor and then you are adding a method to its prototype. This new method (i.e. IsCurrentSite
) does not exists when you pass the youtube
object to writePageInfo
function.
To fix this, you need to call writePageInfo(youtube)
AFTER adding the method to the prototype:
var youtube = new Youtube();
Youtube.prototype.IsCurrentSite = function ()
{
var url = location.href;
if (url.indexOf("youtube.com") > 0)
{
return playerObj != null;
}
return false;
}
writePageInfo(youtube); //moved here
Answering your question, each browser tab (or window) has its own JavaScript environment.