Why won't my dynamic Javascript work with the YouTube widget?
My site sniffs out the users browser settings, and based on what it finds, it loads 1 of three different css files.
The css files call for different column sizes of the page content. Why am I telling you this?
Well, because I created a YouTube widget. I created 3, actually (so I could have 3 different sizes). Based on the users browser settings, I'm using Javascript to dynamically load one of the three widgets.
I do this in lots of places in my site, and haven't had any problems, but for some reason when I do this with the Widgetbox YouTube widget, all I receive on my page is a 1-inch square box that says "No widget found".
Here's the code...it's not throwing any errors. I can't figure out what's happening. Am I unable to call Widgetbox widgets this way?
(I intentionally modified the script tags so I could get this code to post).
The css files call for different column sizes of the page content. Why am I telling you this?
Well, because I created a YouTube widget. I created 3, actually (so I could have 3 different sizes). Based on the users browser settings, I'm using Javascript to dynamically load one of the three widgets.
I do this in lots of places in my site, and haven't had any problems, but for some reason when I do this with the Widgetbox YouTube widget, all I receive on my page is a 1-inch square box that says "No widget found".
Here's the code...it's not throwing any errors. I can't figure out what's happening. Am I unable to call Widgetbox widgets this way?
(I intentionally modified the script tags so I could get this code to post).
script language="javascript" type="text/javascript">
function GetScript(scriptFile) {
return "script type=\"text/javascript\" src=\"http://cdn.widgetserver.com/syndication/subscriber/InsertWidget.js\"><\/script>script>if (WIDGETBOX) WIDGETBOX.renderWidget(\'+ scriptfile\' );<\/script>"
}
function SetScript() {
if (screen.width <= '1024') {
return GetScript('afd166d3-f537-4b26-85e8-b731ca1aa1c6');
}
else if (screen.width > '1024' && screen.width < '1400') {
return GetScript('afd166d3-f537-4b26-85e8-b731ca1aa1c6');
}
else if (screen.width > '1400') {
return GetScript('70e5819e-e86f-4aa0-a85f-cd6d9dd5e09d');
}
else {
return GetScript('afd166d3-f537-4b26-85e8-b731ca1aa1c6');
}
}
document.write(SetScript());
/script>
1
person has this question
I have this question, too!
Tell me when someone answers.
The more people who ask this question, the more it gets noticed.
The more people who ask this question, the more it gets noticed.
-
Inappropriate?Hey Charlie,
Try this (I use the same ID over and over, but you can put in whatever ID's you like) in a script tag
http://pastie.org/private/5wsbcllkrci...
Loading Profile...




