1

我試圖將以下代碼轉換爲添加到HREF代碼的「onClick」事件。我有限的JavaScript體驗,但我知道它可以完成。任何類型的指導將不勝感激。DoubleClick Floodlight onClick

<script type="text/javascript"> 
var axel = Math.random() + ""; 
var a = axel * 10000000000000; 
document.write('<iframe src="https://4607507.fls.doubleclick.net/activityi;src=4607507;type=ustac0;cat=lwt16db;dc_lat=;dc_rdid=;tag_for_child_directed_treatment=;ord=' + a + '?" width="1" height="1" frameborder="0" style="display:none"></iframe>'); 
</script> 
<noscript> 
<iframe src="https://4607507.fls.doubleclick.net/activityi;src=4607507;type=ustac0;cat=lwt16db;dc_lat=;dc_rdid=;tag_for_child_directed_treatment=;ord=1?" width="1" height="1" frameborder="0" style="display:none"></iframe> 
</noscript> 

回答

0

Floodlight documentation說明如何完成這樣的事情:

<head> 
    <script type="text/javascript" id="DoubleClickFloodlightTag"> 
    //<![CDATA[ 
    function FLOOD1(type, cat, u1) { 
      var axel = Math.random()+""; 
      var a = axel * 10000000000000000; 
      var flDiv=document.body.appendChild(document.createElement("div")); 
      flDiv.setAttribute("id","DCLK_FLDiv1"); 
      flDiv.style.position="absolute"; 
      flDiv.style.top="0"; 
      flDiv.style.left="0"; 
      flDiv.style.width="1px"; 
      flDiv.style.height="1px"; 
      flDiv.style.display="none"; 
      flDiv.innerHTML='<iframe id="DCLK_FLIframe1" src="http://12345678.fls.doubleclick.net/activityi;src=12345678;type=' + type + ';cat=' + cat + ';u1=' + u1 + ';ord=' + a + '?" width="1" height="1" frameborder="0"><\/iframe>'; 
    } 
    //]]> 
    </script> 
</head> 

<body> 
    <!-- This is an example of a "onclick" call on a anchor tag --> 
    <a href="http://address_of_page_to_load_or_file_to_download" onclick="FLOOD1('testtype', 'testcat', 'testu1');" target="_blank">Click here to test the tag</a> 
</body> 

這應該主要是讓你有,但還需要定製flDiv.innerHTMLonclick()功能與適當的泛光燈字符串值的項目。