Mozilla VPN is currently experiencing an outage. Our team is actively working to resolve the issue. Please check the status page for real-time updates. Thank you for your patience.

This site will have limited functionality while we undergo maintenance to improve your experience. If an article doesn't solve your issue and you want to ask a question, we have our support community waiting to help you at @FirefoxSupport on Twitter and/r/firefox on Reddit.

Search Support

Avoid support scams. We will never ask you to call or text a phone number or share personal information. Please report suspicious activity using the “Report Abuse” option.

Learn More

I've built JavaScript code that works fine in Chrome but which opens and makes active a completely blank tab in addition to the tab that my software is opening.

  • 4 replies
  • 2 have this problem
  • 2 views
  • Last reply by DIYCaptions

more options

The code in question is simply executing the following Javascript command: window.open(targetPage + youtube_id); The variables there resolve to http://diycaptions.com/php/get_captions_and_subtitles_as_text.php?id=6MBaFL7sCb8. On execution, the page opens in a tab, to be sure, but at the very same time, a second tab opens with the words about:blank in the address bar. That is the tab that becomes active, giving the appearance that the entire process failed.

As I say, this is not a problem at all in Chrome.

The code in question is simply executing the following Javascript command: window.open(targetPage + youtube_id); The variables there resolve to http://diycaptions.com/php/get_captions_and_subtitles_as_text.php?id=6MBaFL7sCb8. On execution, the page opens in a tab, to be sure, but at the very same time, a second tab opens with the words about:blank in the address bar. That is the tab that becomes active, giving the appearance that the entire process failed. As I say, this is not a problem at all in Chrome.

All Replies (4)

more options

Tested and open the given link, no problem observed, no additional Tab.

more options

Here's a short video clip showring the problem. https://www.screencast.com/t/Cuy1nSfOQIcv

more options

Can you post the full JavaScript code of this bookmarklet?

more options

Here's the entire script. I'll put the part that I believe triggers the problem in bold.

<script> function getYTProperties(youtube_id) {

   $.ajax({
           type:"GET",
           url:"http://gdata.youtube.com/feeds/api/videos/"+youtube_id+ "?v=2&fields=published,title,author",
           dataType:"xml",
           success: function(ytdata) {
               //popupObj = $('.yt-vid-popup')
    
               var title = $('title', ytdata).text()
               var published =  new Date( $('published',ytdata).text() )
               var channel = $('author name', ytdata).text()
               window.console.log(title, published, channel);
       },

error: function() {

}, complete: function() {

} }) }

       function parseYtUrl(target) {
           var youtube_id, targetPage, url;
           if (target === "ace") {
               var targetPage = "http://www.diycaptions.com/php/start.php?id=";

url = document.getElementById("urlid").value;

           }

if (target === "srt") {

               var targetPage = "http://get_captions_and_subtitles_as_srt?id=";

url = document.getElementById("urlidsrt").value;

           }

if (target === "text") {

               var targetPage = "http://diycaptions.com/php/get_captions_and_subtitles_as_text.php?id=";

url = document.getElementById("urlidsrt").value;

           }
           
          
           //xindow.console.log(url);
           //xlert(url.length);
           if (url.length !== 11) {
               var regExp = /^.*(youtu.be\/|v\/|u\/\w\/|embed\/|watch\?v=|\&v=)([^#\&\?]*).*/;
               var match = url.match(regExp);
               window.console.log(match[2]);
               if (match && match[2].length == 11) {
                   youtube_id = match[2];
               } 
           } else {
               youtube_id = url;
           }    
           getYTProperties(youtube_id);
           window.open(targetPage + youtube_id);
       }
   </script>