网页javascript特效?js特效素材网
这篇文章给大家聊聊关于网页javascript特效,以及js特效素材网对应的知识点,希望对各位有所帮助,不要忘了收藏本站哦。
javascript常用的特效有哪些
javascript
一种由Netscape的LiveScript发展而来的脚本语言,它提高与Java的兼容性。JavaScript采用HTML页作为其接口
一、Javascript在网页的用法
Javascript加入网页有两种方法:
1、直接加入HTML文档
这是最常用的方法,大部分含有Javascript的网页都采用这种方法,如:
<script language="Javascript">
<!--
document.writeln("这是Javascript!采用直接插入的方法!");
//-Javascript结束-->
</script>
在这个例子中,我们可看到一个新的标签:<script>……</script>,而<script language="Javascript”>用来告诉浏览器这是用Javascript编写的程序,需要调动相应的解释程序进行解释。
HTML的注释标签<!--和-->:用来去掉浏览器所不能识别的Javascript源代码的,这对不支持 Javascript语言的浏览器来说是很有用的。
//-Javascript结束:双斜杠表示 Javascript的注释部分,即从//开始到行尾的字符都被忽略。至于程序中所用到的document.write()函数则表示将括号中的文字输出到窗口中去,这在后面将会详细介绍。另外一点需要注意的是,<script>……</script>的位置并不是固定的,可以包含在< head>......</head>或<body>.....</body>中的任何地方。
2、引用方式如果已经存在一个Javascript源文件(以js为扩展名),则可以采用这种引用的方式,以提高程序代码的利用率。其基本格式如下:
<script src=url language="Javascript"></script>
其中的Url就是程序文件的地址。同样的,这样的语句可以放在HTML文档头部或主体的任何部分。如果要实现“直接插入方式”中所举例子的效果,可以首先创建一个Javascript源代码文件“Script.js”,其内容如下:
document.writeln("这是Javascript!采用直接插入的方法!");
在网页中可以这样调用程序:<script src="Script.js" language="Javascript"></script>。
求一个网页特效的代码
给你两种代码,自己选择。第一种要等全部文字消失后才开始下一轮的滚动,第二种是无缝滚动,也就是还没等最后一句消失,下一次滚动已经开始。新闻链接的滚动大部分都是采取第二种。代码中出现的#号表示链接地址。其余参数自行调整。
<MARQUEE onmouseover=this.stop() onmouseout=this.start() style="LEFT: 0px; POSITION: absolute; line-height:20px;TOP=100px;" scrollAmount=2 direction=up height=120 width=200><font color=#B0D8DC size=2><center><a rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" href="#">你在做什么</a><br>
<br>
<a rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" href="#">我在仰望天空</a><br>
<br>
<a rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" href="#">30度仰望是什么</a><br>
<br>
<a rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" href="#">是我想念她的角度</a><br>
<br>
<a rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" href="#">为什么要把头抬到30度</a><br>
<br>
<a rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" href="#">为了不让我的眼泪掉下来</a><br></MARQUEE>
二、文字向上无缝滚动
<div id=marquees style="height=100px;LEFT: 60px; POSITION: absolute; TOP: 100px;"><font style="font-family:宋体; color:white; font-size:14px;line-height=15px">
<a rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" href="#">你在做什么</a><br>
<br>
<a rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" href="#">我在仰望天空</a><br>
<br>
<a rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" href="#">30度仰望是什么</a><br>
<br>
<a rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" href="#">是我想念她的角度</a><br>
<br>
<a rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" href="#">为什么要把头抬到30度</a><br>
<br>
<a rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" href="#">为了不让我的眼泪掉下来</a><br>
<br>
<br>
<br>
</div>
<script language="JavaScript">
marqueesHeight=100;
stopscroll=false;
with(marquees){
style.width=0;
style.height=marqueesHeight;
style.overflowX="visible";
style.overflowY="hidden";
noWrap=true;
onmouseover=new Function("stopscroll=true");
onmouseout=new Function("stopscroll=false");
}
document.write('<div id="templayer" style="position:absolute;z-index:1;visibility:hidden"></div>');
preTop=0; currentTop=0;
function init(){
templayer.innerHTML="";
while(templayer.offsetHeight<marqueesHeight){
templayer.innerHTML+=marquees.innerHTML;
}
marquees.innerHTML=templayer.innerHTML+templayer.innerHTML;
setInterval("scrollup()",30);
}
document.body.onload=init;
function scrollup(){
if(stopscroll==true) return;
preTop=marquees.scrollTop;
marquees.scrollTop+=1;
if(preTop==marquees.scrollTop){
marquees.scrollTop=templayer.offsetHeight-marqueesHeight;
marquees.scrollTop+=1;
}
}
</script>
怎么在dreamweaver做好的网页中,加入js特效。
在需要添加效果的元素<>里面加上
onclick="某函数()"(鼠标点击触发效果)
onload="某函数()"(进入页面触发效果)
onchange="某函数()"(改变内容触发效果,用于文本输入框)
onmouseover="某函数()"(鼠标移动到元素上触发效果)
onmouseout="某函数()"(鼠标移除元素触发效果)
onmousedown="某函数()"(鼠标正在点击触发效果)
onmouseup="某函数()"(鼠标释放触发效果)
参考网址
例如:
<script type="text/javascript" language="javacript">
function changetext()
{
document.getElementByID("text").innerHTML="Hello Word!";
}
</script>
<a id="text" onclick="changetext()">你好!</a>
<a>元素中使用了onclick,当鼠标点击“你好!”时,会触发changetext()函数,将“你好!”变成“Hello Word!”
需要先了解JS文件里面都有什么函数以及函数的功能再使用。网上下载的一般会有注释函数的功能。
该网站中还有代码的教学
如果你还想了解更多这方面的信息,记得收藏关注本站。