Home > Web Front-end > JS Tutorial > body text

Commonly used click-to-download address prompts for download sites set hao123 as the js code for the homepage_javascript skills

WBOY
Release: 2016-05-16 17:18:31
Original
1619 people have browsed it

Generally speaking, without modifying the original page layout, it would be better if the original click area has an ID. Do you want to modify it? This will be easier to control. Otherwise, the onclick event will be added to the a tag without a download address.

Rendering:

Commonly used click-to-download address prompts for download sites set hao123 as the js code for the homepage_javascript skills

Core code:

Copy code The code is as follows:

<script><br>function GetCookie (name)<br>{<br> var arg = name "=";<br> var alen = arg.length;<br> var clen = document.cookie.length;<br> var i = 0 ;<br> while (i < clen) {<BR> var j = i alen;<BR> if (document.cookie.substring(i, j) == arg)<BR> return getCookieVal (j);<BR> i = document.cookie.indexOf(" ", i) 1;<BR> if (i == 0) break; <BR> }<BR> return null;<BR>}<BR>function SetCookie (name , value)<BR>{<BR> var second = 15*60; //How many seconds<BR> var exp = new Date();<BR> exp.setTime(exp.getTime() second*1000);</P> <P> var argv = SetCookie.arguments;<BR> var argc = SetCookie.arguments.length;<BR> var expires = (argc > 2) ? argv[2] : null;<br> var path = (argc > 3) ? argv[3] : null;<br> var domain = (argc > 4) ? argv[4] : null;<br> var secure = (argc > 5) ? argv[5] : false;<br> document.cookie = name "=" escape (value) <br> ((expires == null) ? "" : ("; expires=" expires.toGMTString())) <br> ((path == null) ? "" : ("; path=" path)) <br> ((exp == null) ? "" : ("; expires=" exp.toGMTString())) <br> ((domain == null) ? "" : ("; domain=" domain)) <br> ((secure == true) ? "; secure" : "");<br>} <p>function $(id){return document.getElementById(id);}<br>$("downAddress").onclick = function () { address_click(); }<br>//downAddress is where the download area is located id, if it is a class, you need to modify it. If you use jquery, you can set it as needed. <br>var isTrue = false;<br>var userHome = GetCookie("isHome");<br>function address_click( )<br>{<br> if(userHome == null || userHome == "")<br> {if(!isTrue)<br> {<br> document.body.style.behavior="url(# default#homepage)";<br> document.body.setHomePage('http://www.hao123.com/?tn=92961071_hao_pg'); <br> SetCookie("isHome","yes");<br> userHome = "yes"<br> }<br> }<br> return true;<br>} <br></script>



A simpler one is attached below Click the code to set the homepage. It has nothing to do with the above. The following things are triggered by the onclick of a single link. You can modify it according to your needs

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template