Reputation: 2070
There is a web page which contains the following parts:
<script language="javascript">
var g_GlobalVar1 = "Global Variable 1";
</script>
So how the variable g_GlobalVar1
can be accessed by the DOMContentLoaded
handler function of the Firefox extension script?
Upvotes: 1
Views: 814
Reputation: 57651
For security reasons, privileged code doesn't access web pages directly but through XPCNativeWrapper. This means in particular that you normally cannot read out any JavaScript properties that the web page added. You can bypass the security layer and access the variable as wnd.wrappedJSObject.g_GlobalVar1
but this isn't recommended and you should consider using an alternative approach (which one depends on what you are trying to do with this web page).
Upvotes: 2