Reputation: 8375
Hey guys I'm getting a syntax error on my var url line but I can't seem to figure out what or why it is, help appreciated
SW.wmode = {
init: function() {
$('iframe').each(function()
var url = $(this).attr("src")
$(this).attr("src",url+"?wmode=transparent")
);
}
}
Upvotes: 0
Views: 203
Reputation: 185933
I refactored your code a bit:
SW.wmode = {
init: function () {
$( 'iframe' ).attr( 'src', function ( i, url ) {
return url + '?wmode=transparent';
});
}
};
Upvotes: 0
Reputation: 4027
Well, you're missing some curly braces... Try running your code through a javascript validator like jshint or jslint to help you catch these things.
Most reasonable text editors will have a plugin that can point out any validation errors on save, so that you don't have to do weird troubleshooting in the browser.. or here! ;)
Here's the valid code:
SW.wmode = {
init: function () {
$('iframe').each( function() {
var url = $(this).attr('src');
$(this).attr('src', url+"?wmode=transparent");
});
}
}
Upvotes: 0
Reputation: 4522
You're missing semicolons after each line's expression, and some braces.
SW.wmode = {
init: function() {
$('iframe').each(function() {
var url = $(this).attr("src");
$(this).attr("src",url+"?wmode=transparent");
});
}
};
Upvotes: 3
Reputation: 2460
try this:
SW.wmode = {
init: function() {
$('iframe').each(function() { //you were missing the brackets
var url = $(this).attr("src")
$(this).attr("src",url+"?wmode=transparent")
});
}
}
Upvotes: 1
Reputation: 10071
You are missing the opening and closing braces of the function argument to each
. Your code should be:
SW.wmode = {
init: function() {
$('iframe').each(function(){
var url = $(this).attr("src")
$(this).attr("src",url+"?wmode=transparent")
});
}
}
Upvotes: 1