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

Asked

Viewed 1,137 times

0

Well I am creating a video library and I need to pass the video corresponding to the image clicked on the page to another page that will 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>
  • Are you using any backend language? How do you access your database?

  • You can pass this as a parameter in PHP, from a searched on how to use parameters from the url in the PT OS itself.

1 answer

2


1) first vc 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 make

<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 javascript video

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

source.setAttribute('src',video);

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

then you just create the video tag without any source

  • well in vdd the path to pag is /web/video-play.html had put wrong, even so it would work?

  • of course you pass after the file name ? pathname=value

  • do not forget to mark as completed if it worked

  • how do I use the value of this variable in a src?

  • edited above. just take a look

  • has some way to do with javascript, and works with src tag video?

  • added in editing with jaca script for tag video

Show 2 more comments

Browser other questions tagged

You are not signed in. Login or sign up in order to post.