How to pass a parameter to be used on another page using html

0

Well I'm creating a video library and I need to pass the video corresponding to the image clicked on the page to another page that would receive the corresponding video

<div class="grid">
  <div class="preview">
      <a href="/web/video-play.html"><img src="video1.png"></a>
      <div class="time">00.20</div>
  </div>
</div>
    
asked by anonymous 01.10.2016 / 01:48

1 answer

2

1) First you will pass your variables to another page by get normally

<a href="/web/video-play.php?v=67452"><img src="video1.png"></a>

On the other page you will do

<script>
    function getUrlVars() {
    var vars = {};
    var parts = window.location.href.replace(/[?&]+([^=&]+)=([^&]*)/gi, function(m,key,value) {
    vars[key] = value;
    });
    return vars;
    }
</script>

can be inside the head and soon after you get past variables like this

<script>
var video= getUrlVars()["v"];
alert(video);
</script>

in a src:

<img src='' id='minhaimg'>
<script>
$("#minhaimg").attr("src", video);
</script>

obs: this using jquery

for full video javascript

var video = document.getElementById('video');
var source = document.createElement('source');

source.setAttribute('src',video);

video.appendChild(source);
video.play();

So you only create the video tag without source none

    
01.10.2016 / 02:03