The topic might be a bit cryptic, but here's my problem (perhaps a n00b-thing?):
For my site I have a widget, that user can use on their site as such (for example):
<script type="text/javascript">
var widget_width ="300";
</script>
<script src="http://something/a.js" type="text/javascript"></script>
Now, in the .js file I want to check if the user have declared the widget_width variable. So I thought I might do something like (I want the variable to be empty, "", because I do a server-side validation too):
if(typeof widget_width == 'undefined') {
var widget_width = "";
}
This didn't work, neither did:
if(!widget_width) {
var widget_width = "";
}
Any ideas on how do declare a variable when needed this way?
remove the var. make it >
if(typeof widget_width == 'undefined') {
widget_width = "";
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With