jQuery + External javascript: How to embed videoplayer in div
- by Dennis
I just started with jQuery and so far I have a really good impression of the framework. But now I have a problem that I can't figure out on myself. I want to embed an external javascript file that loads a videoplayer and displays it. If I include the <script>...</script> directly in HTML it loads just fine. But when I try to load it with jQuery it has very different behaviors in several browsers but it doesn't work in a single one. Either the player is not loaded at all or it doesn't update the selected div but reloads the player on a blank page. This is the source:
<html>
<head>
<style type="text/css">
div#test {
width: 100%;
height: 500px;
margin: 10px auto;
padding: 5px;
border: 1px solid #777;
background-color: #fbca93;
text-align: center;
}
</style>
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.4.1/jquery.min.js"></script>
<script>
$(document).ready(function(){
var video = "<script type=\'text\/javascript\' src=\'http:\/\/www.physicalfitnet.com\/video_syndication\/embed\/jssingle.aspx?vid=651&pub=9DF8233261D101B86368400385B8FF2E\'><\/script>";
$("div#test").html(video);
});
</script>
</head>
<body>
<div id="test"> Hi</div>
</body>
</html>
I uploaded everything to http://kernast.de/test ... any help is appreciated.
THX