网站制作JS

<meta http-equiv="refresh" content="0.1,url=http://www.baidu.com" />网页跳转


每当用浏览器一打开别人的主页时,在浏览器的状态栏上就会出现各种形式的文本提示,而且提示是动态的,提示的内容有的是介绍主页内容的,有的是欢迎的信息等等,这样的提示既不影响浏览主页

的速度,又不影响观看主页,因为它不占据页面的部分,所以很多的主页都应用这种特效。
  要实现这样的特效并不是很难,下面就介绍几种这种特效的应用实例:

  一、眨眼式

  当浏览器打开网页时,下面的状态栏就会像眨眼睛似地出现文本提示信息(提示的内容可以改成你所需要的任意内容)。

<script language=″JavaScript″>
!--
var yourwords =″欢迎光临豆豆网(http://www.ddvip.com)";
var speed = 1000;
var control = 1;
function flash()
{
if (control == 1)
{
window.status=yourwords;
control=0;
}
else
{
window.status=″ ″;
control=1;
}
setTimeout(″flash();″,speed);
}
flash();
</script>
  二、冒泡式

  当浏览器打开网页时,下面的文本就像是冒泡一样,一个字一个字地出现,提示信息同样可以改变成你自己的内容。

  把下面的代码放到主页中的<body>和</body>之间即可

<script language=″JavaScript″>
<!--
var msg =″欢迎光临豆豆网″;
var interval =300
var spacelen = 120;
var space10=″ ″;
var seq=0;
function Scroll() {
len = msg.length;
window.status = msg.substring(0, seq+1);
seq++;
if ( seq 〉= len ) {
seq = 0;
window.status = ′ ′;
window.setTimeout(″Scroll();″, interval );
}
else
window.setTimeout(″Scroll();″, interval );
}
Scroll();
</script>
  三、标题栏出现

  当浏览器打开网页时,上面的标题栏就会移动出现一行提示信息,提示信息可随你改变。

  把下面的代码放到主页中的<body>和</body>之间即可

<script language=″JavaScript″>
<!--Hide me
file://″index_count″ is subtracted from ″title_length″ to get the first # of the substring method
var index_count = 0;
// What you want to scroll in the title bar
var title_string =″欢迎光临豆豆网(http://www.ddvip.com)";
// length of title string
var title_length = title_string.length;
// Variable for setTimeout()
var cmon;
// Counter for clearTimeout()
var kill_length = 0;
function loopTheScroll()
{
scrollTheTitle();
// If greater than length of string then stop calling itself
if(kill_length 〉 title_length)
{
clearTimeout(cmon);
}
kill_length++;
// Calls itself 10x per second - change the value to speed up or slow down the scroll (in 1/1000th of a second)
cmon = setTimeout(″loopTheScroll();″,100)
}
function scrollTheTitle()
{
// Difficult to explain, must be familiar w/ the substring method
var doc_title = title_string.substring((title_length - index_count - 1),title_length);
// put doc_title in the title bar
document.title = doc_title;
index_count++;
}
loopTheScroll();
file://--〉
</script>
  上面是几个简单的特效实例,你自己可以设计出更多这样的特效形式,修改成你自己的特殊风格。怎么样?赶紧在你的主页里动手试试吧。







打字效果的带链接的新闻标题


<html>
<head>
<title>打字效果的带链接的新闻标题</title>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<style type="text/css">
body{font-size:14px;font-weight:bold;}
</style>
</head>
<body>
最新内容:<a id="HotNews" href="" target="_blank"></a>
<SCRIPT LANGUAGE="JavaScript">
<!--
var NewsTime = 2000; //每条新闻的停留时间
var TextTime = 50;   //新闻标题文字出现等待时间,越小越快

var newsi = 0;
var txti = 0;
var txttimer;
var newstimer;

var newstitle = new Array(); //新闻标题
var newshref = new Array();   //新闻链接

newstitle[0] = "fffffffffffffffffff";
newshref[0] = "http://www./";

newstitle[1] = "http://www./";
newshref[1] = "http://www./";

newstitle[2] = "显而易见,最高的效率就是对现有材料的最佳利用。";
newshref[2] = "http://www./";

newstitle[3] = "提高工作效率最有效的方法!";
newshref[3] = "http://www./";

newstitle[4] = "bye";
newshref[4] = "http:///";

function shownew()
{
//code by haiwa @2005-10-21 www.51windows.net
var endstr = "_"
hwnewstr = newstitle[newsi];
newslink = newshref[newsi];
if(txti==(hwnewstr.length-1)){endstr="";}
if(txti>=hwnewstr.length){
   clearInterval(txttimer);
   clearInterval(newstimer);
   newsi++;
   if(newsi>=newstitle.length){
    newsi = 0
   }
   newstimer = setInterval("shownew()",NewsTime);
   txti = 0;
   return;
}
clearInterval(txttimer);
document.getElementById("HotNews").href=newslink;
document.getElementById("HotNews").innerHTML = hwnewstr.substring(0,txti+1)+endstr;
txti++;
txttimer = setInterval("shownew()",TextTime);
}
shownew();
//-->
</SCRIPT>
</body>
</html>
原文地址:https://www.cnblogs.com/shihao/p/1517425.html