Javascript函数和事件
一、默认函数
JavaScript提供了一些默认的函数
编码函数escape():将非字母、数字字符转换成ASCII码
译码函数unescape():将ASCII码转换成字母、数字字符
求值函数eval()
数值判断函数isNaN():判断一个值是否为非数值类型
整数转换函数parseInt():将不同进制(二、八、十六进制)的数值转换成十进制整数
浮点数转换函数parseFloat():将数值字串转换成浮点数
1、eval()函数
求值函数eval()的格式为:eval(<表达式>)
下面的例子将用eval函数得到一个文本框的值,
然后通过点击按钮弹出一个对话框将其输出。
<script>
function show(obj)
{
var str=eval("document.Form."+obj+".value");
alert(“你输入的姓名是:”+str);
}
</script>
<form name="Form" id="Form">
姓名:
<input name="name" type="text" value="韦小宝">
<input name="button" type="button" value="提交" onClick=show("name")>
</form>
2、isNaN()函数
数值判断函数isNaN()的格式:isNaN(<量>)
下例中isNaN函数将判断变量是否不是数值,并输出判断结果。
<script>
var x=15;
var y="黄雅玲";
document.write("<LI>x不是数值吗?",isNaN(x));
document.write("<LI>y不是数值吗?",isNaN(y));
</script>
3、parseInt()函数
整数转换函数parseInt()的功能是将不同进制(二、八、十六)的数值转换成十进制整数。
格式:parseInt(数值字串[,底数])
下面演示了将一个二进制数和一个十六进制数转换成十进制数。
<script>
document.write("1101<sub>2</sub>=",parseInt("1101",2),"<sub>10</sub><br>");
document.write("BFFF<sub>16</sub>=",parseInt("BFFF",16),"<sub>10</sub><br>");
</script>
4、parseFloat()函数
parseFloat()是浮点数
相关文档:
scrollHeight: 获取对象的滚动高度。
scrollLeft:设置或获取位于对象左边界和窗口中目前可见内容的最左端之间的距离
scrollTop:设置或获取位于对象最顶端和窗口中可见内容的最顶端之间的距离
scrollWidth:获取对象的滚动宽度
offsetHeight:获取对象相对于版面或由父坐标 offsetParent 属性指定的父坐标的高度
offsetL ......
JavaScript动态加载CSS的三种方法 收藏
如果你有很多关联的CSS文件要一起加载,或者想动态的加载不同的CSS文件,那么下面的方法你一定对你有帮助。
第一种:一般用在外部CSS文件中加载必须的文件
程序代码
@import url(style.css);
/*只能用在CSS文件中或者style标签中*/
第二种:简单的在页面中加载一 ......
//获取页面数据
function getPageSize(){
var xScroll, yScroll;
if (window.innerHeight && window.scrollMaxY) {
xScroll = document.body.scrollWidth;
yScroll = window.inn ......
JavaScript API
One of the new features we added to the ASP.Net Report Viewer in Visual Studio 2010 is a JavaScript API to allow you to interact with the viewer on client. In reading many of the posts on the report controls forum, we found that many people struggle when implementing a custom ......