I am trying to access the window level variable in my script in the window.onLoad()
, but it always returns undefined
. But when I console log it or try to just type in the window
in the debug console, it clearly shows me the variable exists on window
object and has a value. I am unclear why this is happening and is there a way to access it? Please correct me if I am doing something wrong and point me in the right direction. Any help is greatly appreciated.
Update: The window._vp
variable is declared in the script of some live website and I am trying to access that particular variable using my chrome extension.
My script:
window.onload = _ => {
console.log("window._vp is:", window._vp);
}
Website script:
var _vp = {};
_vp['IsDashAvailable'] = false;
//...
You can see the behavior in the following screenshot of the dev tool console:
Thank you.