Camen Design Forum

Delete

(Leave this as-is, it’s a trap!)

To delete this post you must be either the original author or a designated moderator.
The content of the post will be removed but the name and date will remain.

  • The post will be removed completely from the thread, rather than blanked
  • Only posts on the last page of the thread can be removed completely (so as to not break permalinks)

RE: Passing Variables via URL

Nikolai

To get the variable in the <source> tag, you need to use the DOM. Try something like this:

var videoFile = getQueryVariable("v");
var videoElement = document.getElementById("mp4source");
videoElement.setAttribute("source", videoFile + ".mp4");

In which case you should add the ID attribute to the <source> tag, with the value of "mp4source". The above code gets the v parameter from the URI using your function, the second finds the page element of the ID "mp4", while the last line sets the source attribute to the desired one.

Furthermore, if you wish there is a video when you don't have a query variable, you can alter the first line so it goes like this:

var videoFile = (getQueryVariable("v") !== "") ? getQueryVariable("v") : "myothervideo";

Which has a fallback value should the URL lacks the v parameter.

Your friendly neighbourhood moderators: Kroc, Impressed, Martijn