Download station common click download address prompt set hao123 as the home page js code

  • 2020-03-26 21:44:03
  • OfStack

In general, we do not change the original layout of the page, if the original click area has an id is better, do not want to change it, this is easier to control, otherwise there will be an onclick event in the a tag of the download address.

Effect:

< img border = 0 SRC = "/ / files.jb51.net/file_images/article/201310/20131028115630.gif" >

Core code:


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


Attached below is a simpler click to set the home page of the code, as the above, the following thing is triggered by a single link of onclick, you can change as needed

 
 
 
 
 The first click on the link prompt is set as the home page  
 
 
 
 
 
 
 script home 
 
 
[Ctrl+A]


Related articles: