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.
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.
Alle svar (4)
Tested and open the given link, no problem observed, no additional Tab.
Here's a short video clip showring the problem. https://www.screencast.com/t/Cuy1nSfOQIcv
Can you post the full JavaScript code of this bookmarklet?
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>