搜索 | 用户支持

防范以用户支持为名的诈骗。我们绝对不会要求您拨打电话或发送短信,及提供任何个人信息。请使用“举报滥用”选项报告涉及违规的行为。

详细了解

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 个回答
  • 2 人有此问题
  • 2 次查看
  • 最后回复者为 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.

所有回复 (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>