Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/413.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript Firefox:window.open阻止img.src加载_Javascript_Image_Firefox_Window.open - Fatal编程技术网

Javascript Firefox:window.open阻止img.src加载

Javascript Firefox:window.open阻止img.src加载,javascript,image,firefox,window.open,Javascript,Image,Firefox,Window.open,我听到一些谣言,我似乎无法复制。现在我很好奇你们中是否有人对这个问题有经验 我们的分析系统使用JavaScript生成1x1像素的图像。这张“图片”记录了我们所有访客的行为 function visitLink (url) { var img = new Image(); img.src = 'http://www.meshfields.com/' + url; document.getElementById("myImgId").src = img

我听到一些谣言,我似乎无法复制。现在我很好奇你们中是否有人对这个问题有经验

我们的分析系统使用JavaScript生成1x1像素的图像。这张“图片”记录了我们所有访客的行为

function visitLink (url)
    {
      var img = new Image();
      img.src = 'http://www.meshfields.com/' + url;

      document.getElementById("myImgId").src = img.src;      
      window.open("http://www.meshfields.com/index.html");
    }

现在考虑以下简化的JavaScript代码:

function visitLink (url)
{
  var randomNumber = Math.random();

  var img = new Image();
  img.src = 'http://www.example.com/log?url=' + escape(url) + '&' + randomNumber;

  window.open(link.href);

  return false;
}
谣言说,;window.open可以在某些版本的FireFox中阻止img.src的后台加载

但它在我的FireFox版本中运行。我在这里看到鬼了吗?若否,;你知道如何复制这个问题吗


Erik

据我所知,JavaScript是一种单线程语言,从上到下解释函数

因此,如果应该阻止某些内容,则是打开窗口,而不是加载图像。我的一句简短的责备确实表明了这种行为

function visitLink (url)
    {
      var img = new Image();
      img.src = 'http://www.meshfields.com/' + url;

      document.getElementById("myImgId").src = img.src;      
      window.open("http://www.meshfields.com/index.html");
    }
标记:

 <a href="javascript:visitLink('myBigPicture.jpg');">Link</a>

 <img id="myId" src="" />
所有浏览器在加载pic时都没有问题。在Safari、Chrome、Firefox和MacOSX上的Opera上测试。然而,我显然没有使用你的内部分析系统来生成我的照片