Important Update: Community URLs redirect issues are partially resolved. Learn More. .

cancel
Showing results for 
Search instead for 
Did you mean: 

Switching attributes with JavaScript

WojciechProcele
Contributor II

Hi all,
I am trying to code switching src attribute of video html tag using buttons in Custom iView,
I have following code:

 

<!DOCTYPE html>
<html>
<head>
<meta name="viewport" content="width=device-width, initial-scale=1">
<script language="javascript">

function load_vid_01(){
 document.getElementById("srcMp4").src = "video/2.mp4";
 document.getElementById("srcOgg").src = "video/2.mp4";
 document.getElementById("trainVid").load();
}

</script>

</head>

<body>

<div class="mainBox">
<div class="leftBox">
<ul class="buttons">

 

<li>

<button onclick="load_vid_01()">
Button Content
</button>

</li>

 

</ul>

</div>
<div class="rightBox">

<video controls align="right" id="trainVid">

  <source src="video.mp4" type="video/mp4" id="srcMp4">
  <source src="video.ogg" type="video/ogg" id="srcOgg">

  Your browser does not support the video tag.

</video>
</div>

</div>

</body>

</html>

 

which is working in editors like jsfiddle but seems to not work in Archer Custom iView. I am new to customizing his views so I am not sure what I am missing. Source src attribute is not being updated with following function.

9 REPLIES 9

jsol5
Advocate II

If it works locally it's because your video files are most likely in the same location/path -  "video/2.mp4"

However, Archer on a server won't know that path.

 

 

WojciechProcele
Contributor II

I am providing full patch to video in src attribute and trying to change it to other one in the same format. (in ex.

src="<example.site - full path.com>/vid01.mp4 to

src="<example.site - full path.com>/vid02.mp4)

HTML5 limitation?

What do you see when you look at debugger tools in your browser console window?

"HTTPS security is compromised by <my provided path>".

 

What I also forgot to mention is that tag itself work properly, if I provide src in Source tag directly, video is loading properly, just function that switch this attribute is not working.

This is an IE issue when it encounters mixed content: HTTP and HTTPs.

Do you suggest any workaround ?

Mm, probably you need to use the same protocol and files maybe located on the Archer server.

I thought you were using HTTPS even for the videos.

So, other than being on the same server (hopefully, you're on-prem for this).

The only other thing I could think of would be a hyperlink to an internal site that contains the videos.

I gotta believe that the video exists in more than one place.

 

I was also wondering about creating a new tab or pop-up with it embedded, but I don't know if these solutions would give you the same issue.  I haven't done much with video so a little at a loss there.

jsol5
Advocate II

I think there's also a option for iviews to have video.

Maybe you can use that and point the user to the iview?