一些下载网站总是诱惑用户先点击广告然后才能显示真实的软件下载地址,究竟是怎么实现的呢?我找了一个javascript代码,大家可以看看:
<!-- 开始 --> <base target="_blank" onclick="javascript:will()" /> <script language="JavaScript" type="text/javascript"> function will() { if (event.srcElement.tagName=='A'||event.srcElement.tagName=='IMG') { window.focus(); oUrl.style.display = ""; yAd.style.display = "none"; document.cookie='goodfont=yes'; } } function get_cookie(Name) { var search = Name + "=" var returnvalue = ""; if (document.cookie.length > 0) { offset = document.cookie.indexOf(search) if (offset != -1) { // if cookie exists offset += search.length // set index of beginning of value end = document.cookie.indexOf(";", offset); // set index of end of cookie value if (end == -1) end = document.cookie.length; returnvalue=unescape(document.cookie.substring(offset, end)) } } return returnvalue; } </script> <!-- 广告代码开始 --> <div id="yAd"> <a href='http://weste.net' target=_blank>点此一下就能显示下载地址</a> </div> <!-- 广告代码结束 --> <div id="oUrl" style="display:'none'"> <script language="javascript">function JyDownH(htmlurl){var newwin=window.open(htmlurl,'','toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=no,resizable=no');return false;} </script> <A href='http://cc163.driversky.com/down/KuiBu_inst.exe' target=_blank>真实下载地址</A> </div> <!-- 结束 -->