Thank you for your help. I forgot to copy the } after the alert(videoName). So myFunction ends after alert. var playerURL... is not part of the function. I'm trying to take the script out of the function. I'll post back the result.
wfzen
Posts
-
variable undefined -
variable undefinedI want to extract a video name from XML and put it in the URL parameter. I copied the XML reading code from w3school. See below:
//var videoName; the name of the video
var tPath = ... the URL to the XML
var var2 = ... the filename of an XML
var xmlhttp = new XMLHttpRequest();
xmlhttp.onreadystatechange = function() {
if (this.readyState == 4 && this.status == 200) {
myFunction(this);
}
};
xmlhttp.open("GET", tPath, true);
xmlhttp.send();
function myFunction(xml) {
var x, xmlDoc, videoName;
xmlDoc = xml.responseXML;
x = xmlDoc.getElementsByTagName("videoName")[0];
videoName = (x.textContent);
alert (videoName);
}
var playerURL = "http://" + getCookie("MediaServerGeneral") + "/IVP/demo.htm?XMLName=" + var2 + "&MediaFileName=" + videoName;I see the name of the video in alert. but the playerURL has videoName shown as undefined. my XML is like this, and I'm trying to pick up "videoName.mp4":
videoName.mp4
What is wrong with the script? Thanks,
-
Add a dynamic label to video selectedThanks for the help. I still can't get it to work. Chrome Javascript console says Uncaught TypeError: Object #<HTMLDocument> has no method 'writeIn' Can you give hint on the approach you prefer? I'm a newbie on Javascript. Thanks,
-
Add a dynamic label to video selectedI have the following to play a video dynamically by specify the media name and its path. There are multiple links on the same page. A user can click on each link to play a video.
I'd also like to add a label somewhere on the screen so the user knows which video he is playing. I tried the following, by calling getTitle with a number to output the title of the video. The problem is it replace the whole screen instead of placing it somewhere on the screen. So how can I achieve what i need? Thanks for your help,
function getTitle(tTitle)
{
myTitle = ""
if (tTitle == 1) {
myTitle = "video 1"
} else if (tTitle == 2) {
myTitle = "video 2"
} else if (tTitle == 3) {
myTitle = "Video 3"
} else if (tTitle == 4) {
myTitle = "Video 4"
}document.write("
");
document.write("Now Playing: " + myTitle);}
-
include javascript within document writeI use Dreamweaver to generate the rollover Javascript code to something like this:
document.write("[");](http://astringforURL=" + theCourseCode + ")
[IT does the link OK not the rollover anymore with this. I think it may relate to the single quotes it had initially and I had to change the double quotes into single quotes while retaining the single quote. I can't put the script to do rollover outside either. How can I make it work? Thanks,](http://astringforURL=" + theCourseCode + ")