vietean
vietean

Reputation: 3033

Passing arguments to javascript file, how does it work?

From the tutorial ScriptJSONOptions of FirebugLite page, I found the below:


Script JSON options

It is possible to set options using a JSON object inside the linked script:

<script type="text/javascript" 
src="https://getfirebug.com/firebug-lite.js">
{
    overrideConsole: false,
    startInNewWindow: true,
    startOpened: true,
    enableTrace: true
}
</script>

It means that we can pass the arguments to javascript file.
But I don't know how does it work?

Update:

My question is how to get the arguments inside the js file?

P/S:

I also looked into code, but I could not find the code is implemented this feature.

Upvotes: 2

Views: 324

Answers (1)

lcapra
lcapra

Reputation: 1540

I think this can be achieved by finding the correct "script" dom node and then eval() its text content. In jQuery

 eval("var mySettings = " + jQuery("script[src*='firebug']").text() );

Upvotes: 1

Related Questions