导航:首页 > 万维百科 > javascript网页设计

javascript网页设计

发布时间:2020-08-23 13:37:25

1、JavaScript网页设计,求代码!

<body>
<p>请输入您的姓名</p>
<p><input id=txt type="text" /><input id=btn type="button" value="输入测试" onclick=test1() /></p>
<script>
var txt=document.getElementById('txt')
var btn=document.getElementById('btn')
function test1(){
if(txt.value==''){
alert('没输入任何数据')
}else{
alert(txt.value+'输入完成')
}
}

</script>
</body>

2、网页设计中Javascript有多重要

在当今的网络时代,制作网站已不再是高不可攀的技术,但要制作出有良好交互性、功能强大的网站并非易事。JavaScript技术可以实现交互式页面,在建立动态页面方面有着其他工具不可比拟的优点。
Javascript 在网页设计中,大部分都是用来实现功能,特效的..
当然 Web2.0如火如荼,其中关键技术之一就是JavaScript,例如Ajax技术就是以JavaScript为基础的。

回到题问 . 其实老实说, Javascript应该算是网页设计人员必备掌握的技术. 如果伱只会单纯的使用Dreamweaver等那些傻瓜式工具,实在是堪称失败..

程序员对JavaScript的不重视,直接导致了JavaScript被忽视;而大量互联网特效应用,加速了JS被地当作一种脚本。而直到Jesse James Garrett 把JavaScript XMLhttp DOM等组合在一起正式提出Ajax后,JavaScript才忽然地炙手可热起来。加上Google、Yahoo、Microsoft等大型公司在Ajax方面的大量应用,JavaScript随着Ajax也越来越受到关注。

而使用JavaScript,至少有下面这几点好处:
1,增加交互动态应用,丰富界面应用,提高用户体验
2,节省后台开发成本,减少后台开发量, 显示HTML/XHTML和格式化数据交给JS处理
3,节省网络带宽,让浏览速度更快,减轻服务器压力,XMLhttp 减少刷新数据
4,体现RIA,B/S模式的利器,通过JS可以达到C/S模式的效果
5,WEB版软件最好的界面实现者,Flash,Applet也还不错,不过目前JavaScrip是最好的
6,……

下面参考地址的链接 里面有实例 伱可以自己去看
http://www.blueidea.com/tech/web/2007/4390.asp
要从事网页设计 加油了!!

3、html5网页制作+javascript

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>test</title>
<script type="text/javascript">
 function Student(id, name, gender, birthday, score) {
        this.id = id;
 this.name = name;
 this.gender = gender;
 this.birthday = birthday;
 this.score = score;
 this.study = function () {
            this.score = this.score === 100 ? this.score : this.score += 1;
 };
 this.getAge = function () {
            return new Date().getFullYear() - new Date(birthday).getFullYear()
        };
 }
 
    var student = new Student(1,'张三','男','1996-2-12',20);
 console.log('学习成绩:'+student.score);
 console.log('年龄:'+student.getAge());
 student.study();
 console.log('学习成绩:'+student.score); //学分加1
 student.study();
 console.log('学习成绩:'+student.score); //学分加1
</script>
<body>
请打开浏览器控制台查看日志输出效果。
</body>
</html>

4、网页设计里什么能用javascript

CSS和JavaScript是制作网页常用到的两种语言,不属于Dreamweaver,Dreamweaver只是制作网页的一种工具,做网页可以使用CSS和JavaScript也可以不使用,也就是说用Dreamweaver可以使用CSS和JavaScript也可以不使用。

可以理解为,css让房子里的东西摆好位置,但不能动,JS却可以重新把布局进行更换
js主要用于客户端,属于客户端脚本语言(是弱类型的程序),CSS只能美化网页,对网页进行布局,功能单一

5、网页设计中常用的javascript脚本有哪些

$(“a[href=’#top’]”).click(function() {   

$(“html, body”).animate({ scrollTop: 0 }, “slow”);   

return false;   

});  

复制以上代码放在网页的JavaScript标签中,然后在底部添加一个id为“top”的链接就会自动返回到顶部了。

2、复制表单顶部标题到底部:

var $tfoot = $(‘<tfoot></tfoot>’);   

$($(‘thead’).clone(true, true).children().get().reverse()).each(function(){   

$tfoot.append($(this));   

});   

$tfoot.insertAfter(‘table thead’);  

3、载入额外的内容:

$(“#content”).load(“somefile.html”, function(response, status, xhr) {   

// error handling   

if(status == “error”) {   

$(“#content”).html(“An error occured: “ + xhr.status + ” “ + xhr.statusText);   

}   

});  

有时候需要为单独的一个div层从外部载入一些额外的数据内容,下面这段短码将会非常有用。

4、设置多列层等高:

var maxheight = 0;   

$(“div.col”).each(function(){   

if($(this).height() > maxheight) { maxheight = $(this).height(); }   

});   

$(“div.col”).height(maxheight);  

在一些布局设计中,有时候需要让两个div层高度相当,下面是采用js方法实现的原理(需要等高的div层设置class为”col”)。

5、定时刷新部分页面的内容:

setInterval(function() {   

$(“#refresh”).load(location.href+” #refresh>*”,“”);   

}, 10000); // milliseconds to wait  

如果在你的网页上需要定时的刷新一些内容,例如微博消息或者实况转播,为了不让用户繁琐的刷新整个页面,可以采用下面这段代码来定时刷新部分页面内容。

6、预载入图像:

$.preloadImages = function() {   

for(var i = 0; i<arguments.length; i++) {   

$(“<img />”).attr(“src”, arguments[i]);   

}   

}   

$(document).ready(function() {   

$.preloadImages(“hoverimage1.jpg”,“hoverimage2.jpg”);   

});  

有些网站页面打开图像都未载入完毕,还要苦苦等待。下面这段代码实现图像都载入完毕后再打开整个网页。

7、测试密码强度:
这个比较给力,现在很多网站注册的时候都加入了密码强度测试功能,以下代码也简单提供了密码强度测试功能。

HTML代码部分:

<input type=“password” name=“pass” id=“pass” />  

<span id=“passstrength”></span>  

JavaScript脚本代码:

$(‘#pass’).keyup(function(e) {   

var strongRegex = new RegExp(“^(?=.{8,})(?=.*[A-Z])(?=.*[a-z])(?=.*[0-9])(?=.*W).*$”, “g”);   

var mediumRegex = new RegExp(“^(?=.{7,})(((?=.*[A-Z])(?=.*[a-z]))|((?=.*[A-Z])(?=.*[0-9]))|((?=.*[a-z])(?=.*[0-9]))).*$”, “g”);   

var enoughRegex = new RegExp(“(?=.{6,}).*”, “g”);   

if (false == enoughRegex.test($(this).val())) {   

$(‘#passstrength’).html(‘More Characters’);   

} else if (strongRegex.test($(this).val())) {   

$(‘#passstrength’).className = ‘ok’;   

$(‘#passstrength’).html(‘Strong!’);   

} else if (mediumRegex.test($(this).val())) {   

$(‘#passstrength’).className = ‘alert’;   

$(‘#passstrength’).html(‘Medium!’);   

} else {   

$(‘#passstrength’).className = ‘error’;   

$(‘#passstrength’).html(‘Weak!’);   

}   

return true;   

});  

8、自适应缩放图像:
有时候网站上传的图像需要填充整个指定区域,但是有时候图像比例并不恰好合适,缩放后效果不好。一下代码就实现了检测图像比例然后做适当的缩放功能。

$(window).bind(“load”, function() {   

// IMAGE RESIZE   

$(‘#proct_cat_list img’).each(function() {   

var maxWidth = 120;   

var maxHeight = 120;   

var ratio = 0;   

var width = $(this).width();   

var height = $(this).height();   

if(width > maxWidth){   

ratio = maxWidth / width;   

$(this).css(“width”, maxWidth);   

$(this).css(“height”, height * ratio);   

height = height * ratio;   

}   

var width = $(this).width();   

var height = $(this).height();   

if(height > maxHeight){   

ratio = maxHeight / height;   

$(this).css(“height”, maxHeight);   

$(this).css(“width”, width * ratio);   

width = width * ratio;   

}   

});   

//$(“#contentpage img”).show();   

// IMAGE RESIZE   

});  

9、自动载入内容:
现在很多网站,特别是微博,都不需要翻页的按钮了,直接下拉后会自动载入内容。下面的脚本就是简单实现了个这种效果。

var loading = false;   

$(window).scroll(function(){   

if((($(window).scrollTop()+$(window).height())+250)>=$(document).height()){   

if(loading == false){   

loading = true;   

$(‘#loadingbar’).css(“display”,“block”);   

$.get(“load.php?start=”+$(‘#loaded_max’).val(), function(loaded){   

$(‘body’).append(loaded);   

$(‘#loaded_max’).val(parseInt($(‘#loaded_max’).val())+50);   

$(‘#loadingbar’).css(“display”,“none”);   

loading = false;   

});   

}   

}   

});   

$(document).ready(function() {   

$(‘#loaded_max’).val(50);   

});  

6、网页设计里的js文件是什么

有问题找百度,不要这么懒

先在网页一般都会用javascript实现页面的动态效果,甚至用Ajax(javascript+XML)实现异步通信效果。

用到javascript代码的页面中,javascript代码的存放位置总共有三种情况:
1. 在<script></script>标签中间
2. 在各个标签的< ... onClick="javacript代码" /> 中
3. 外置的javascript代码,就是以 .js 文件形式存在

7、在网页制作中javascript是什么意思

Javascript是一种脚本语言,它可以增强静态Web应用的功能,从而为Web页面提供动态的、个性化的内容,通过Javascript还可以与用户进行交互。
说白了,html控制网页的内容,css控制网页的样式,Javascript就是控制网页的行为。

8、求 HTML+CSS+JavaScript网页设计从入门到精通 胡晓霞版的书籍PDF 谢谢!

与javascript网页设计相关的知识