I was wondering if there is a way that I can pass variables like this:
<script type="text/javascript">
width = 300;
</script>
<script type="text/javascript">
(function(){
var k = width;
alert(k);
});
</script>
I'm trying to learn how I can pass width into the variable k. I dont want to do var width =300 Is there a way to do such a thing like this? so eventually I can place the bottom script, (function(){...}); into a file where I can just do this
<script type="text/javascript">
width = 300;
//more variables if needed
//height = 300;
//name = "example";
//...
</script>
<script type="text/javascript" src="thefile.js"></script>
So I can add more variables if I have to
Thanks!
()before the semicolon to invoke your function.