Jump to content

Replacing a script or portion thereof) mid-page


thesoundsmith

Recommended Posts

I am running an audio player with large playlist. I wish to reload the actual playlist with noew data. There is a function in the player, but other constraints make it unusable, so I am trying to simply(?) replace the HTML text.The original uses PHP includes to load the playlist, but I am assuming I cannot reload the PHP via js, so I gave the entire <script> an ID and am trying to replace the section with another, different list. The paragraph descrition changes perfectly, but the new playlist text does not load.The page is at: http://www.thesoundsmith.com/radioTST.htm The scripts are in the PHP direcetory and I have saved them as TXT files, but the innerHTML of the section does not change.What am i doing wrong? The call is

document.getElementById("library").innerHTML="php/radez.txt";   

(or php/radsmoo.txt, etc.)and the script in the body is:

 document.getElementById("mStyl").innerHTML="<i>DashRadio: Smooth Electronica</i><br />All the smooth, mellow and/or spiritual/meditation-styled compositions";<script id="library" type="text/javascript">    jwplayer("container").setup({	    flashplayer: "/jwplayer/player.swf",	    playlist: [<?php require("php/phpradioBIG.php"); ?>	    ],	    skin: 'skinz/car2/car2.xml',	   "playlist.position": "bottom",	    "playlist.size": 80,	    shuffle: "true",	    autostart: "true",	    height: 480,	    width: 480 ,	    repeat: 'always'    });</script>

This original php list is quite long, but works fine. When I change the library, the "mStyl" text updates, the playlist does not.Any ideas appreciated. This function currently uses five pages, I'd like to get it all working on one.

Link to comment
Share on other sites

Doing that doesn't work for Javascript, trying to replace the contents of a script tag does not cause the browser to execute that code. I would look into using the built-in function to change the playlist, the alternative would be to remove the existing player entirely from the page, add the elements back, and add Javascript code that runs setup again. I'm assuming that running setup twice on the same thing isn't going to work correctly.

Link to comment
Share on other sites

Thanks. The built-in function has never worked for me in IE. But it probably IS me, not the code. I could back it up and replace the whole DIV, perhaps. I have not tried re-running setup, but I believe you're correct. I'll try to fix the playlist reload, it may be easier in the end - and it IS more correct...

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...