- <script type="text/javascript">
- var sosoInitHint = "";
- var sosoCurrHighLight = document.getElementById("sosoweb"), frm_head = document.getElementById('frm_head'), delayId = null;
- var sosoTmpArr = ['神七 最新动态','输入天气,本地温度即时播报','国内股市实时动态','输入个税,在线计算所得税'];
- var sosoTmpArr2 = ['神七','天气','股市','个税'];
- var sosoRandom = Math.floor(Math.random()*sosoTmpArr.length);
- sosoInitHint = sosoTmpArr[sosoRandom];
- sosoInitKw = sosoTmpArr2[sosoRandom];
- window.setTimeout(setFun,1);
- function setFun()
- {
- frm_head = document.getElementById('frm_head');
- frm_head.w.value = sosoInitHint;
- }
- var sosoInitHint2 = sosoInitHint;
- function trim(str){
- return str.replace(/(^\s*)|(\s*$)/g, "");
- }
- function sosoValidate(){
- wval = trim(frm_head.w.value);
- if( (wval == sosoInitHint2) || (wval == sosoInitHint) )
- {
- frm_head.w.value="";
- frm_head.w.style.color="#000";
- if (frm_head.sc.value=="web")
- {
- frm_head.w.value=sosoInitKw;
- frm_head.action = "http://www.soso.com/q";
- }
- return true;}
- if(frm_head.sc.value=="post")
- {
- frm_head.bn.value = frm_head.w.value;
- frm_head.op.value = "enterbar";
- }
- else if(frm_head.sc.value=="wenwen" && wval != "")
- {
- window.open("http://wenwen.soso.com/z/SearchSolved.e?cid=w.q.in.sb.ww&sp=S"+encodeURIComponent(frm_head.w.value), "_blank");
- return false;
- }
- if(wval == "")
- return false;
- else {
- return true;
- }
- }
- function delaySubSearch(sc) {
- if (delayId) clearTimeout(delayId);
- delayId = setTimeout(function() {
- sosoSubSearch(sc);
- }, 500);
- }
-
- function cancelDelay() {
- if (delayId) clearTimeout(delayId);
- }
- function sosoSubSearch(sc){
- changePage(sc);
- frm_head.w.blur();
- frm_head.sc.value = sc;
- wval = trim(frm_head.w.value);
-
- if(sc == "img")
- {
- frm_head.action = "http://image.soso.com/image.cgi";
- }
- else if(sc == "mus")
- {
- frm_head.action = "http://music.soso.com/music.cgi";
- }
- else if(sc == "forum")
- {
- frm_head.action = "http://bbs.soso.com/b.q";
- }
- else if(sc == "qz")
- {
- frm_head.action = "http://qzone.soso.com/qz.q";
- }
- else if(sc == "soba"){
- frm_head.sc.value = "post";
- sosoGoSoba();
- }
- else if(sc == "wenwen")
- {
- frm_head.sc.value = "wenwen";
- frm_head.action = "http://wenwen.soso.com/z/SearchSolved.e";
- }
- else
- {
- frm_head.action = "http://www.soso.com/q";
- }
- frm_head.w.focus();
- }
- function sosoGoSoba(){
- frm_head.action = "http://post.soso.com/sobar.q";
- }
- function changePage(sc){
- if(sosoCurrHighLight == null){
- sosoCurrHighLight = document.getElementById("sosoweb");
- }
- sosoCurrHighLight.className = "s2";
- if(sc == "qz")
- sosoCurrHighLight = document.getElementById("sosoqzone");
- else sosoCurrHighLight = document.getElementById("soso" + sc);
- sosoCurrHighLight.className = "s1";
- frm_head.sc.value = sc;
- frm_head.cid.value= "w.q.in.sb." + sc;
-
- }
- function isSoba(){
- if(sosoCurrHighLight == document.getElementById("sososoba")){
- sosoGoSoba();
- return true;
- }
- else{
- return true;
- }
- }
- function goSearch(){
- //changeHotWords(document.frm_head.sc.value);
- if(!sosoValidate())
- return false;
- if(frm_head.w.value != ""){
- frm_head.submit();
- frm_head.bn.value = "";
- frm_head.op.value = "";
- }
- else
- return false;
- }
- function focusVerify()
- {
- var frm_head = document.getElementById("frm_head");
- var vi = frm_head.w;
- if( (vi.value == sosoInitHint2) || (vi.value == sosoInitHint))
- {vi.value=''; vi.style.color="#000";}
- }
- function blurVerify()
- {
- var vi= frm_head.w;
- if(vi.value=='')
- {
- if(document.getElementById("sosoweb").className == "s1")
- {
- vi.value = sosoInitHint;
- }else
- {
- vi.value = sosoInitHint2;
- }
- vi.style.color="#ccc";
- }
- }
- function changeHotWords(category){
- document.getElementById("td_hotlist").innerHTML = eval(category + "Words");
- }
- function togDispMore(e){stopB(e);var elems=document.getElementsByName('tm');for(var i=0;i<elems.length;i++){var obj=elems[i],dp="";if(obj.style.display==""){dp="none";}obj.style.display=dp;}return false;}
- function stopB(e){if(!e)e=window.event;e.cancelBubble=true;}
- document.onmouseup=function(event){var elems=document.getElementsByName('tm');if(elems[0].style.display==""){togDispMore(event);}}
- function tp(obj){
- var frm_head_w = document.frm_head.w.value;
- if(frm_head_w.length>0 && (frm_head_w !=sosoInitHint && frm_head_w != sosoInitHint2))
- {
- var oh=obj.href;
- obj.href = obj.href.replace(/w=.+/g,"w=");
- obj.href = obj.href.replace(/SearchSolved\.e\?sp=S.+/g,"SearchSolved.e?sp=S");
-
- var qw=document.frm_head.w.value.trim();
- if(obj.href.indexOf("wenwen") != -1)
- {
- obj.href = obj.href + encodeURIComponent(qw);
- }else{
- obj.href=obj.href+qw;
- }
-
- }else{
- obj.href = "http://"+obj.hostname;
- }
- }
- String.prototype.trim=function()
- {
- return this.replace(/(^\s*)|(\s*$)/g,'');
- }
- $d = function(id){
- return document.getElementById(id);
- }
- var st='';
- function sm(event)
- {
- clearTimeout(st);
- eventSrc = event.srcElement || event.target;
- o=$d('tm');
- if( eventSrc.tagName == "H3")
- {
- tt = setTimeout(function(){o.style.display="block";document.onmousemove = cp;},800);
- }else
- {
- clearTimeout(st);
- o.style.display="block";
- document.onmousemove = cp;
- }
-
-
- }
- function cp(event)
- {
- evt = window.event?window.event:event;
- var pointer=function(event) {
- return {
- x: event.pageX || (event.clientX +
- (document.documentElement.scrollLeft || document.body.scrollLeft)),
- y: event.pageY || (event.clientY +
- (document.documentElement.scrollTop || document.body.scrollTop))
- };
- }(evt);
- l=o.offsetLeft;t = o.offsetTop-20;
- r=l+o.offsetWidth;b=o.offsetTop+o.offsetHeight;
-
- py = pointer.y;px = pointer.x;
- if((py>t && py<b && px>l&&px<r)){
- }
- else{
- st = setTimeout(function(){o.style.display="none";},500);
- document.onmousemove=function(){};
- }
- }
- function formatSoso()
- {
- var o1=$(arguments[0]);var t1=arguments[1];var n1 = arguments[2];var c1 = arguments[3];var c2 = arguments[4];
- var f=getNames(o1,n1,t1);
- for(i=0;i<f.length;i++)
- {
- f[i].value = i;
- f[i].onmouseover = function(){ cplay(o1,this.value,t1,n1,c1,c2); };
- }
- }
- </script>
- <script src="http://www.soso.com/js/smart_for_qq.js"></script>
复制代码 免费下载,本人也正在仿制首页,但有一段代码不是很熟悉,是js的
因为这段代码,使滑动不生效,那位js高手帮看看,哪里有问题
代码
腾讯首页.rar
(417.49 KB, 下载次数: 931)
|