Js编程小技巧(不断积累中)
来源:互联网 发布:北大青鸟软件培训课程 编辑:程序博客网 时间:2024/06/14 13:44
在项目开发的时候,经常会要求实现一些js方面的小功能。因此记录在这里供以后参考:
1.javascript 打开CHM文件
window.showHelp("../jscript56.chm");
2.一个免费的天气预报插件
将以下代码拷入页面就可以直接显示
<iframe src="http://m.weather.com.cn/m/pn12/weather.htm " width="245" height="110" marginwidth="0" marginheight="0" hspace="0" vspace="0" frameborder="0" scrolling="no"></iframe>
3.日历控件:http://www.goocnjp.com/data/tools/calendar.html
4.创建表头固定,表体可滚动的GridView
<script type="text/javascript">
function s()
{
var t = document.getElementById("<%=GridView1.ClientID%>");
var t2 = t.cloneNode(true)
for(i = t2.rows.length -1;i > 0;i--)
t2.deleteRow(i)
t.deleteRow(0)
a.appendChild(t2)
}
window.onload = s
</script>
<form id="Form1" runat="server">
<table>
<tr>
<td>
<div id="a">
</div>
<div style="overflow-y: scroll; height: 200px;table-layout:fixed">
<asp:GridView ID="GridView1" runat="server" Font-Size="12px" BackColor="#FFFFFF"
GridLines="Both" CellPadding="4" Width="560">
<HeaderStyle BackColor="#EDEDED" Height="26px" />
</asp:GridView>
</div>
</td>
</tr>
</table>
</form>
5.防止页面被拷贝的方法
在body中加入下面代码,再加上去掉工具栏,菜单,别人就很难拷贝你的代码
<Body onselectstart="return false" onmousemove = "document.selection.empty();" onmouseup="document.selection.empty();" oncopy ="document.selection.empty();" onselect = "document.selection.empty();" oncontextmenu="return false">
6.IE6 情况下让PNG图片透明的方法
<script language="javascript">// 修复 IE 下 PNG 图片不能透明显示的问题function fixPNG(myImage) {var arVersion = navigator.appVersion.split("MSIE");var version = parseFloat(arVersion[1]);if ((version >= 5.5) && (version < 7) && (document.body.filters)){ var imgID = (myImage.id) ? "id='" + myImage.id + "' " : ""; var imgClass = (myImage.className) ? "class='" + myImage.className + "' " : ""; var imgTitle = (myImage.title) ? "title='" + myImage.title + "' " : "title='" + myImage.alt + "' "; var imgStyle = "display:inline-block;" + myImage.style.cssText; var strNewHTML = "<span " + imgID + imgClass + imgTitle + " style=\"" + "width:" + myImage.width + "px; height:" + myImage.height + "px;" + imgStyle + ";" + "filter:progid:DXImageTransform.Microsoft.AlphaImageLoader" + "(src=\'" + myImage.src + "\', sizingMethod='scale');\"></span>"; myImage.outerHTML = strNewHTML;} } window.onload=function(){ document.getElementById("top").style.height=screen.height/5+"px"; }//</script>用法如下:<img src="logo.png" width="328" height="325" border="0" onload="fixPNG(this)" />
7.多为数四舍五入的通用方法:
//num表示要的数,v表示要保留的小数位数。
function decimal(num,v)
{
var vv = Math.pow(10,v);
return Math.round(num*vv)/vv;
}
- Js编程小技巧(不断积累中)
- C#编程小技巧(不断积累中)
- QTP 小技巧不断积累更新
- matlab 编程小技巧积累
- Android编程小技巧积累
- [原创] QTP 小技巧不断积累更新(…
- js常用技巧(不断收集整理中)
- Spring [boot] 使用技巧集合-不断积累
- Web开发常用小技巧 -- JavaScript[不断添加中...]
- 常用Java类型转化小技巧(不断添加中)
- java编程中一些小建议积累
- 小技巧积累
- 小技巧积累
- iOS 小技巧积累
- MFC 小技巧积累
- MFC小技巧积累
- 小技巧的积累
- photoshop小技巧积累
- WP7-文件下载进度和速度显示
- 网站管理系统
- 庆祝找回csdn的密码散分顺带推广下偶的小站
- 一天学会MVC3之Scaffolding
- Ogre 正常初始化(0xc0150002)失败 解决办法
- Js编程小技巧(不断积累中)
- IE9 "已停止工作" 的解决办法
- xCAT2安装配置
- Excel数据库
- ORA-02142: missing or invalid ALTER TABLESPACE option
- makefile常用语法讲解(1)
- Abbreviation
- WP7-silverlight控件实现立体翻转效果
- makefile常用讲解(2)