Javin007
asked on
Simple Javascript question:
Here is the entire code I have for my site:
Inside of "test.js" is just a simple "console.log("Test 3");" and a setOptions function that takes 1 variable. In that function is a console.log("Test 4");
What I would EXPECT to happen:
For the console to show :
Test 1
Test 2
Test 3
Test 4
(Or some variant of that in some order).
Instead, all I get is "Test 3". I assume I'm doing something wrong in the actual script code here.
<script defer="defer" src = "test.js">
console.log("Test 1");
setOptions({
UseFooter: true,
UseHeader: true,
Classification: "None",
Style: "default.css"
});
console.log("Test 2");
</script>
Inside of "test.js" is just a simple "console.log("Test 3");" and a setOptions function that takes 1 variable. In that function is a console.log("Test 4");
What I would EXPECT to happen:
For the console to show :
Test 1
Test 2
Test 3
Test 4
(Or some variant of that in some order).
Instead, all I get is "Test 3". I assume I'm doing something wrong in the actual script code here.
ASKER
Yeah, I kinda figured that was the problem, so tried it your recommended way. Unfortunately, that way, it doesn't seem to recognize that "setOptions()" is an existing function (presumably because it hasn't actually loaded yet).
What's the "correct" way to pass parameters to a Javascript plugin?
What's the "correct" way to pass parameters to a Javascript plugin?
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Ah, thanks!
this will not work as the inline script will never get executed as you have both inline script and an external reference (src).
Just use this and it should work as expected:
Open in new window
See also an explanation:http://ejohn.org/blog/degrading-script-tags/
HTH
Rainer