Hi guys,
Complete novice at jarascript here, I used to do a fair bit of php but never really touched javascript. Im just trying to bodge something together using code I have found on the internet to play movies in a browser.
I am using the following code to get a movie file name from the URL (eg – [url]www.mywebsite.com/movies.html?file=filename):
[CODE]<script>
function gup( name )
{
name = name.replace(/[[]/,”\[“).replace(/[]]/,”\]”);
var regexS = “[\?&]”+name+”=([^&#]*)”;
var regex = new RegExp( regexS );
var results = regex.exec( window.location.href );
if( results == null )
return “”;
else
return results[1];
}
var file = gup(‘file’);
</script>
How do I then insert the variable into the following code to get the correct movie to display?
[code=html]
<video class=”centre” width=”auto” height=”90%” controls>
<source src=”movies/VARIABLE FILE NAME HERE” type=”video/mp4″>
</video>
In php I would echo the variable into the src so in javascript I thought I could use document.write(file); however that didnt work and after a bit of research I found that using document.write is bad practice.
All help greatly appreciated.
Thanks