You can change this JS code to open the link in another tab when clicked

0

I do not code anything. If anyone can help me. This is below the JS code ... it opens on the same tab the video ... if you have how to change the code to open in a popup or new tab, I would appreciate it.

$(function() {

  var videohtml5 = $('.videoGallery .videohtml5');
  var liHeight = $('.videoGallery li').height();

  // BLOGGER
  videohtml5.click(function() {
    var videoID = $(this).attr('data-videoID');
    var videos = $('<div class="meuVideo"><center> <video width="100%" controls="controls" autoplay="true" poster="https://i.imgur.com/SoclbRY.png" src="https://www.blogger.com/video-play.mp4?contentId='+videoID+'" type="video/mp4"></video></center> </div>');

    $('.meuVideo, .nowPlaying').remove();
    $(this).parents().eq(2).append(videos);

  });

  // Fechar Videos
  $('.close').click(function() {
    $('.meuVideo, .nowPlaying').remove();
  });

})
    
asked by anonymous 12.10.2017 / 02:59

1 answer

0

You can do this with the function window.open() and then inserting the HTML with document.write . Note that I changed the variable videos by taking the parentheses and the $ :

$(function() {

  var videohtml5 = $('.videoGallery .videohtml5');
  var liHeight = $('.videoGallery li').height();

  // BLOGGER
  videohtml5.click(function() {
    var videoID = $(this).attr('data-videoID');
    var videos = '<div class="meuVideo"><center> <video width="100%" controls="controls" autoplay="true" poster="https://i.imgur.com/SoclbRY.png" src="https://www.blogger.com/video-play.mp4?contentId='+videoID+'" type="video/mp4"></video></center> </div>';

    // Abro uma janela popup
    video_popup = window.open("pagina_da_popup.html","video_popup","width=400, height=200");

    $('.meuVideo, .nowPlaying').remove();

    // Insiro os dados na popup
    video_popup.document.write(videos);

  });

  // Fechar Videos
  $('.close').click(function() {
    $('.meuVideo, .nowPlaying').remove();
  });

})
  

Note: Where page_of_popup.html does not necessarily have to be an existing page on the server. Even if you do not put anything   in the URL (so: video_popup = window.open("","video_popup","width=400, height=200"); ) will work, because the popup is just a window   browser, and does not necessarily have to have a URL. It will only appear, before the document.write takes action, the message HTTP Error 404.0 - Not Found .

    
12.10.2017 / 03:31