定时自动转页
<script>setTimeout('document.location.href="[url]"',5000)</script>
返回前一页
<a href="javascript:history.back()">返 回</a>
弹出消息窗口
<script>window.alert("hi!");</script>")
定焦点到文本框的末尾
规范帖子中的图片
js文件中的中文问题
web application的编码规则是utf-8,那么js文件中如果有中文就会出现乱码(有可能是其它的页面不正常的情况)
解决这个问题请在引用javascript的地方加上charset="gb2312"或者charset="big5"
例如:<script type="text/javascript" language="javascript" src="scripts/function.js" charset="gb2312"></script>
<script>setTimeout('document.location.href="[url]"',5000)</script>
返回前一页
<a href="javascript:history.back()">返 回</a>
弹出消息窗口
<script>window.alert("hi!");</script>")
定焦点到文本框的末尾
function focusEnd(){ if(field.createTextRange){ var r = field.reateTextRange(); r.moveStart('character',field.value.length); r.collapse(); r.select(); } } |
规范帖子中的图片
<img οnlοad='javascript:if(this.width>790)this.style.width=790;' οnclick='javascript:window.open(this.src);' style='CURSOR:hand' onmousewheel='return bbimg(this)'> function bbimg(o){ var zoom=parseInt(o.style.zoom, 10)||100;zoom+=event.wheelDelta/12;if (zoom>0) o.style.zoom=zoom+'%'; return false; } |
js文件中的中文问题
web application的编码规则是utf-8,那么js文件中如果有中文就会出现乱码(有可能是其它的页面不正常的情况)
解决这个问题请在引用javascript的地方加上charset="gb2312"或者charset="big5"
例如:<script type="text/javascript" language="javascript" src="scripts/function.js" charset="gb2312"></script>