📄 bdun.htm
字号:
<DIV id=top></DIV></DIV>
<DIV id=temp></DIV>
<SCRIPT type=text/javascript>
function G(id){return document.getElementById(id);}
var objcurtab = G('a2').parentNode;
//alert(objcurtab);
var objform = document.f2;
function go() {
if(objform.name == "f1") objform.word.value = G('kwip').value;
if(objform.name == "f2") objform.wd.value = G('kwip').value;
if(objform.name == "f3") {
objform.kw.value = G('kwip').value;
objform.word.value = G('kwip').value;
}
if(objform.name == "f4") objform.word.value = G('kwip').value;
if(objform.name == "f5") objform.word.value = G('kwip').value;
if(objform.name == "f6") objform.word.value = G('kwip').value;
if(objform.name == "f7") objform.word.value = G('kwip').value;
objform.submit();
return false;
}
function switchTab() {
objcurtab.className = "";
//alert(this.parentNode.nodeName);
this.parentNode.className = "active";
objcurtab = this.parentNode;
objform = document["f" + this.id.substr(1)];
return false;
}
for(var i=1;i<=7;i++){
G('a'+i).onclick=switchTab;
}
G('kwip').onfocus=function(){
this.style.color='#000';
if(this.value=='请输入关键词')
this.value='';
}
G('kwip').onblur=function(){
if(!this.value){
this.value='请输入关键词';
this.style.color='#ccc';
}
}
var MaxCount = arr_civilnews.length;
var Current = 0;
var Single = 5;
var ImgCurrent = 0;
var Col = 2;
var ImgArray = [];
var Imgtemp = 0;
var tid = 0;
var $URL = 'http://www.baidu.com/s?tn=sh1000_pg&fyb=1&wd='; //搜索地址
var $defaultImg = ['http://unstat.baidu.com/code/multinews/default1.gif', 'http://unstat.baidu.com/code/multinews/default2.gif', 'http://unstat.baidu.com/code/multinews/default3.gif', 'http://unstat.baidu.com/code/multinews/default4.gif']; //默认图片
var $defaultImgWord = ['百度新闻', '百度新闻', '百度新闻', '百度新闻']; //默认关键词
var $defaultImgPath = 'http://unstat.baidu.com/code/multinews';
function getTitle (str) {
if (str.indexOf(' ') >= 0) {
return str.substr(0, str.indexOf(' '));
}
return str;
}
function transImgArray () {
for (var i = 0 ; i < MaxCount ; i++) {
if (arr_civilnews[i].src != '') {
ImgArray[ImgArray.length] = arr_civilnews[i].src;
}
}
}
function createTemp () {
var str = [];
for (var i = 0 ; i < ImgArray.length ; i++){
str.push('<span><a onclick="submitLinkForm(this);return false;" text="' + getTitle(arr_civilnews[ImgCurrent].title) + '" href="#"><img align="middle" src="'+ $defaultImgPath+ImgArray[ImgCurrent]+'" onload="resizeImg(this)" /></a></span>');
ImgCurrent++;
}
G('temp').innerHTML = str.join('');
}
function resizeImg (imgEl) {
var width = imgEl.offsetWidth , height = imgEl.offsetHeight;
var b = width / height;
if (width > height) {
width = 57;
height=57/b;
} else {
height = 51;
width = 51 *b;
}
imgEl.width = width;
imgEl.height = height;
if(window.attachEvent){
if(height == 51 && width == 57){
imgEl.style.top = 0;
imgEl.style.left = 0;
} else if (height == 51){
imgEl.style.top = 0;
imgEl.style.marginLeft = parseInt(-width/2) + "px";
} else if (width == 57) {
imgEl.style.left = 0;
imgEl.style.marginTop = parseInt(-height/2) + "px";
}
}
}
function addImg (id, num) {
var coneEl = G('temp').getElementsByTagName('span')[num].cloneNode(true);
G(id).appendChild(coneEl);
}
var HotShow = {
module: function () {
var newDivEl = document.createElement('div');
G('top').appendChild(newDivEl);
newDivEl.className = 'modle';
var k = 0;
for (var j = 0; j< Col; j++ ) {
var tempDivEl = document.createElement('div');
tempDivEl.className = 'chunk';
newDivEl.appendChild(tempDivEl);
for (var i = 0 ; i < Single ; i++) {
if (i < 2) {
if(ImgArray.length > 3){
Imgtemp = (Imgtemp < ImgArray.length ) ? Imgtemp : 0;
var id = 'img' + tid;
tempDivEl.innerHTML += '<p class="pic" id="' + id + '"></p>';
addImg (id ,Imgtemp);
tid++;
Imgtemp++;
} else {
if(Imgtemp < ImgArray.length){
var id = 'img' + tid;
tempDivEl.innerHTML += '<p class="pic" id="' + id + '"></p>';
addImg (id ,Imgtemp);
tid++;
} else {
tempDivEl.innerHTML += '<p class="pic"><span><a onclick="submitLinkForm(this);return false;" text="' + $defaultImgWord[k] + '" href="#"><img src="'+ $defaultImg[k] +'" onload="resizeImg(this);" /></a></span></p>';
k++;
}
Imgtemp++;
Imgtemp = (Imgtemp == 4) ? 0 : Imgtemp;
}
} else {
Current = (Current < MaxCount ) ? Current : 0;
tempDivEl.innerHTML += '<p><a href="#" text="' + getTitle(arr_civilnews[Current].title) + '" onclick="submitLinkForm(this);return false;">'+ getTitle(arr_civilnews[Current].title) +'</a></p>';
Current++;
}
}
}
newDivEl.style.top = newDivEl.offsetHeight +'px';
},
create: function () {
for (var k = 0 ; k < 4; k++) {
this.module();
}
},
seat: function () {
G('top').getElementsByTagName("div")[0].style.top = 0;
},
roll: function () {
var divEl = G('top').getElementsByTagName("div");
var divHeight = divEl[0].offsetHeight;
var Timer;
var j = 0;
Timer = setInterval(function () {
divEl[0].style.top = --j + 'px';
divEl[1+Col].style.top = (--j + divHeight )+ 'px';
if (j < -divHeight){
clearInterval(Timer);
G('top').removeChild(divEl[0]);
HotShow.seat();
setTimeout(HotShow.roll,12000);
if (G('top').childNodes.length < 3) {
HotShow.create();
}
}
},10);
},
init: function () {
transImgArray();
createTemp();
this.create();
this.seat();
setTimeout(this.roll,12000);
}
}
function submitLinkForm (aEl) {
var formEl = document.forms['linkForm'];
formEl['wd'].value = aEl.getAttribute('text');
formEl.submit();
}
window.onload = function (){
document.baidu.onsubmit=go;
HotShow.init();
}
</SCRIPT>
</BODY></HTML>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -