I'm working on a banner ad which links to an iframe that displays youtube videos for different used vehicles. I have a hand-coded file that works fine to swap out the video source, depending on the vehicle listed, with jQuery, but in GWD it sticks on the default URL, and console doesn't appear to generate any errors. The code:
var video_id = $(results_xml[result_index]).find('video_embed_code').text();
video_id = video_id.substring(video_id.indexOf("watch?v=")+8,video_id.length);
video_id = "https://www.youtube.com/embed/"+video_id;
$('#tap_video').attr('src',video_id);
targeting iframe...
<iframe class="gwd-iframe-wyk3" id="tap_video" src="https://www.youtube.com/embed/hjdcZq35PcU"></iframe>
XML data on our server is parsed for the embed code and appended to the URL for each vehicle. The iframe is added as a manual tag as the iframe component in GWD refers to the URL as "source" rather than "src", and the youtube embed calls it "video-url". I thought maybe since the jQuery was looking for attribute "src" this was the cause, but it doesn't seem so. Any help would be great.
-Matt-
The issue here seems to be that the iframe and src aren't loaded until the event to navigate to that expanded page is fired. GWD must set the value of the page as hidden, so its not loading initially? The trouble now is if I execute a command to change the iframe source onLoad, it runs each time the new URL loads and gets stuck in a loop. Any ideas?
-Matt-
-Matt-
-Matt-
-Matt-
I tested this out, and the variable does not seem to be defaulting back to a string, which is great. However, the video will still only play the first time, and subsequent plays by clicking my "Video" button just yield an error message. The URL on the second playback is always "https://www.youtube.com/watch", so it doesn't seem to be loading the variable that second time, and is left blank (I've left the source field blank in the component properties too, so it seems to be loading that as a blank value on the second play?). Since I need the video source to change with each new vehicle, I'm wondering if having the Video ID change on pageload of the expanded page where the Youtube component is maybe isn't the best option? Would that cause it to only set the ID the first time it loads?
-Matt-
Failed to execute 'postMessage' on 'DOMWindow': The target origin provided ('https://www.youtube.com') does not match the recipient window's origin ('null').
-Matt-
-Matt-
-Matt-