Show BLOB in iframe src

Asked

Viewed 221 times

-1

Good afternoon, I’m here posting my doubt because I’ve tried some workarunds to get what I want and I’m not getting.

My goal is to first hide the main link that is in the database. Let’s assume that the link that is stored is www.google.com*

<img src="img/server.png" class="img-thumbnail servidor" data-videolink="www.google.com" data-server="servername"/>

Here I call (with echo PHP) the data-videolink which is the link that is stored in the database. But instead of showing www.google.com I would like you to show a blob (ie hiding the original address as I already explained)

This is my j

$(document).ready(function () {
    $('#servidores-bg .servidor').click(function () {
        $('.container > #servidores-bg').hide();
        var videolink = $(this).data('videolink');  
//$('#servidores-player').prepend("<iframe src='"+videolink+"' id='player' scrolling='no' frameborder='0' allowfullscreen='true' webkitallowfullscreen='true' mozallowfullscreen='true'></iframe>"); <---- PREVIOUS CODE LINE
        $('#servidores-player').prepend("<iframe id='player'></iframe>");

        var html = ``; <-- A ideia que tive foi colocar o iframe com a src original da base de dados ao clicar na imagem com o data-video link mas percebi que não faz sentido isso :(
        var blob = new Blob([html], {type: 'text/html'});
        var iframe = document.querySelector("#player");
        iframe.src = URL.createObjectURL(blob);
    });
});

Any help? I’m really stuck here

  • But what’s the point of doing all this if at the end you put the url in the iframe src? Opening the element inspector will show the url the same way.

  • Because I really need

1 answer

0

You already have the Blob, then just turn it into text again:

$(document).ready(function () {
  $('.servidor').click(function () {
    $('#servidores-bg').hide();
    var videolink = $(this).data('videolink');  
    $('#servidores-player').prepend("<iframe id='player'></iframe>");
    var blob = new Blob([videolink], {type: 'text/html'});
    var iframe = document.querySelector("#player");
    //transforma o blob em texto
    blob.text().then(url => iframe.src = url);
  });
});
  • That’s not what I’m looking for. Supposedly the BLOB should be on data-videolink. Thus: data-videolink="blob:43334-34334-5657-5757" and when I click <img data-videolink="blob:43334-34334-5657-5757"> calls the original database link as: $('#servidores-player').prepend("<iframe src='"+videolink+"' id='player' scrolling='no' frameborder='0' allowfullscreen='true' webkitallowfullscreen='true' mozallowfullscreen='true'></iframe>");

Browser other questions tagged

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