Uncaught reference error: function is not defined javascript
I wrote a function with parameters and I am trying to call that function.
However, I keep getting "Uncaught reference error: "function" is not
defined.
Here is my code:
var bColor, fColor, fStyle, bUrl;
jQuery(function changeBackground(bColor, fColor, fStyle, bUrl) {
if (typeof (bColor) === 'undefined') bColor = '#fff';
if (typeof (bUrl) === 'undefined') bUrl = '';
if (typeof (fColor) === 'undefined') fColor = '#000';
if (typeof (fStyle) === 'undefined') fStyle = 'Monda';
WebFontConfig = {
google: { families: [ fStyle ] }
};
(function() {
var wf = document.createElement('script');
wf.src = ('https:' == document.location.protocol ? 'https' : 'http') +
'://ajax.googleapis.com/ajax/libs/webfont/1/webfont.js';
wf.type = 'text/javascript';
wf.async = 'true';
var s = document.getElementsByTagName('script')[0];
s.parentNode.insertBefore(wf, s);
})();
jQuery('body').css({ backgroundColor: bColor, backgroundUrl: bUrl, color:
fColor, fontFamily: fStyle });
});
I get the error regardless of if I run the function from the script. Or if
I run it via any of the element calls e.g. onload.
I have no idea why I am getting the error maybe another set of eyes can
spot my mistake.
No comments:
Post a Comment