English 中文(简体)
触发目标= Java的空白链接
原标题:Triggering a target=_blank link from JavaScript
  • 时间:2011-03-12 01:46:48
  •  标签:
  • javascript

这是一个新生事物。

我有外部联系。

<a href="http://www.example.com" target="_blank">

现在,我希望每当连接点点点点击时,追踪谷歌·阿多德斯的转换。

为此,我增列一个<代码>click的活动,该活动含有谷歌图像。 图像是指转换。 为了绝对确保图像在用户离开之前被装上,我使用图像<代码><>load/code>活动着手实现原始链接指标。

$("#linkname").click(function() {

 var element = document.createElement("img");
 element.onload = function() { ..... };
 element.setAttribute("src", "http://www.googleadservices.com/....");
 document.body.appendChild(element); 

 });

This will work fine using location.href. However, it won t work for target="blank" links. I m baffled as to what to put into the onload function in order to open a new window.

  • 我可以使用<条码>window. open,因为它将被人pop住。 (因其位于图像onload上。) 这一事件看上去的只是方案性的呼吁,与被点击的联系毫无关系。 此外,电话窗口。 在没有任何选择的情况下开放,对谷歌 Chrome没有任何控制。

  • I can t make the click event continue its normal course because I have to wait until the image is loaded, which is an asynchronous operation!

我基本上需要的是打开<代码>target=_blank”的途径,这种方式在方案上连接起来,可能无法做到这一点,因为它可能受到波长老的干扰。

或者,在让连接点的原始<条码>click时,我还需要可靠地计算点击。 活动继续如期进行。

没有人会想什么?

最佳回答

由于链接在新窗口中打开,你实际上不必等到图像装上。 让目前窗口中的图像负荷(正在做的)并使用户看到新的窗口是正常的。 用户在装上图像之前就不太可能关闭窗户,因此该数字不会受到干扰。

问题回答

我不敢肯定,如果你能够(由于某些要求)这样做的话:

Try to open a new window with no location, but on the real click event (not in the onload of the image), but open this window with width and height 0, and puts its x and y in somewhere not visible by the user, or less visible as possible. Keep a reference to this window.

On the onload event of your image, change the location of the new window s url, and then resize and reposition the new window.

希望会发挥作用。





相关问题
selected text in iframe

How to get a selected text inside a iframe. I my page i m having a iframe which is editable true. So how can i get the selected text in that iframe.

How to fire event handlers on the link using javascript

I would like to click a link in my page using javascript. I would like to Fire event handlers on the link without navigating. How can this be done? This has to work both in firefox and Internet ...

How to Add script codes before the </body> tag ASP.NET

Heres the problem, In Masterpage, the google analytics code were pasted before the end of body tag. In ASPX page, I need to generate a script (google addItem tracker) using codebehind ClientScript ...

Clipboard access using Javascript - sans Flash?

Is there a reliable way to access the client machine s clipboard using Javascript? I continue to run into permissions issues when attempting to do this. How does Google Docs do this? Do they use ...

javascript debugging question

I have a large javascript which I didn t write but I need to use it and I m slowely going trough it trying to figure out what does it do and how, I m using alert to print out what it does but now I ...

Parsing date like twitter

I ve made a little forum and I want parse the date on newest posts like twitter, you know "posted 40 minutes ago ","posted 1 hour ago"... What s the best way ? Thanx.

热门标签