The code below works as is. I want to use this code to display specific Twitch streams based on the page that is loaded.
<script type="text/javascript">
var stream = location.pathname;
switch (stream) {
case "/defatank":
document.write("Defatank's Live Stream Page");
break;
case "/seeingblue":
document.write("SeeingBlue's Live Stream Page");
break;
case "/shiroshii":
document.write("Shiroshii's Live Stream Page");
break;
case "/theend66":
document.write("TheEnd66's Live Stream Page");
break;
case "/wakawaka647":
document.write("WakaWaka647's Live Stream Page");
break;
case "/xtheguythatplays":
document.write("XTheGuyThatPlays' Live Stream Page");
break;
}
</script>
When I try to replace
"Defatank's Live Stream Page"
with the object below it doesn't work and breaks the rest of the cases.
<object type="application/x-shockwave-flash" height="378" width="620" id="live_embed_player_flash" data="http://www.twitch.tv/widgets/live_embed_player.swf?channel=defatank" bgcolor="#000000"><param name="allowFullScreen" value="true" /><param name="allowScriptAccess" value="always" /><param name="allowNetworking" value="all" /><param name="movie" value="http://www.twitch.tv/widgets/live_embed_player.swf" /><param name="flashvars" value="hostname=www.twitch.tv&channel=defatank&auto_play=true&start_volume=25" /></object>
I'm sure I'm probably using document.write wrongly or should be using something entirely different. Any suggestions?
EDIT: Here is what the finished product looks like.
<script type="text/javascript">
var stream = location.pathname;
switch (stream) {
case "/defatank":
document.write("<object type="application/x-shockwave-flash" height="378" width="620" id="live_embed_player_flash" data="http://www.twitch.tv/widgets/live_embed_player.swf?channel=defatank" bgcolor="#000000"><param name="allowFullScreen" value="true" /><param name="allowScriptAccess" value="always" /><param name="allowNetworking" value="all" /><param name="movie" value="http://www.twitch.tv/widgets/live_embed_player.swf" /><param name="flashvars" value="hostname=www.twitch.tv&channel=defatank&auto_play=true&start_volume=25" /></object>");
break;
case "/seeingblue":
document.write("SeeingBlue's Live Stream Page");
break;
case "/shiroshii":
document.write("Shiroshii's Live Stream Page");
break;
case "/theend66":
document.write("TheEnd66's Live Stream Page");
break;
case "/wakawaka647":
document.write("WakaWaka647's Live Stream Page");
break;
case "/xtheguythatplays":
document.write("XTheGuyThatPlays' Live Stream Page");
break;
}
</script>
I also tried removing the "" from document.write() and it still dont load and breaks the rest of the cases.