种简单好用的js实例代码网页Word格式文档下载.docx
- 文档编号:1500927
- 上传时间:2023-04-30
- 格式:DOCX
- 页数:10
- 大小:13.02KB
种简单好用的js实例代码网页Word格式文档下载.docx
《种简单好用的js实例代码网页Word格式文档下载.docx》由会员分享,可在线阅读,更多相关《种简单好用的js实例代码网页Word格式文档下载.docx(10页珍藏版)》请在冰点文库上搜索。
/script>
刷新按钮二
刷新按钮二"
history.go(0)"
6、回首页按钮
首页"
HomeButton()"
functionHomeButton(){location.href=;
7、弹出警告框
弹出警告框"
AlertButton()"
functionAlertButton(){window.alert("
要多多光临呀!
);
8、状态栏信息
状态栏信息"
StatusButton()"
functionStatusButton(){window.status="
9、背景色变换
背景色变换"
BgButton()"
functionBgButton(){
if(document.bgColor==’#00ffff’)
{document.bgColor=’#ffffff’;
}
else{document.bgColor=’#00ffff’;
10、打开新窗口
打开新窗口"
NewWindow()"
functionNewWindow(){window.open("
c01.htm"
"
height=240,width=340,status=no,location=no,toolbar=no,directories=no,menubar=no"
11、窗口最小化
OBJECTid="
min"
type="
application/x-oleobject"
classid="
clsid:
adb880a6-d8ff-11cf-9377-00aa003b7a11"
PARAMname="
Command"
Minimize"
/OBJECT>
buttononClick="
min.Click()"
窗口最小化<
/button>
12、全屏代码
BUTTON"
FullScreen"
全屏显示"
window.open(document.location,’butong_net’,’fullscreen’)"
13、关闭窗口
OBJECTid=closestype="
paramname="
Close"
/object>
关闭窗口"
closes.Click();
关闭窗口
inputtype=buttonvalue=关闭窗口onClick="
javascript:
self.close()"
14、最大化
objectid=bigclassid="
ADB880A6-D8FF-11CF-9377-00AA003B7A11"
Maximize"
inputtype=buttonvalue=最大化onClick=big.Click()>
15、关闭输入法
inputstyle="
ime-mode:
disabled"
value=关闭输入法>
16、链接按钮1
链接按钮1"
window.open(’’Sample’,’toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=no,resizable=yes,copyhistory=yes,width=790,height=520,left=0,top=0’)"
input"
链接按钮2
NAME="
Button"
链接按钮2"
showModalDialog(’
链接按钮3
submit"
链接按钮3"
location.href=’
17、警告框显示源代码
BUTTONonClick=alert(document.documentElement.outerHTML)style="
width:
110"
警告框显示源代码<
/BUTTON>
18、点击后按钮清空
inputtype=buttonvalue=’打印’onClick="
this.style.visibility=’hidden’;
window.print();
19、打印
20、打印预览
OBJECTclassid="
CLSID:
8856F961-340A-11D0-A96B-00C04FD705A2"
height=0id=wbname=wbwidth=0>
inputtype=buttonvalue=打印预览onclick="
wb.execwb(7,1)"
21、另存为
inputonClick="
document.execCommand(’saveas’,’true’,’常用代码.htm’)"
type=buttonvalue=另存为>
22、点击自动复制
functionoCopy(obj){obj.select();
js=obj.createTextRange();
js.execCommand("
Copy"
)}<
text"
点击自动复制"
oCopy(this)"
size="
11"
23、自动选中
inputvalue="
自动选中"
onFocus="
this.select()"
onMouseOver="
this.focus()"
24、打开源代码
BUTTONonClick="
document.location=’view-source:
’+document.location"
7"
打开源代码<
25、新窗口延迟打开
inputtype=buttonvalue=新窗口延迟打开onClick=javascript:
setTimeout("
window.open(’
26、实现选中文本框里的前一半的内容
选中文本框里的前一半的内容"
size=30onmouseover="
this.select();
tR=document.selection.createRange();
tR.moveEnd(’character’,-8);
tR.select();
选中部分内容,非IE可以用这个"
this.selectionStart=this.value.length-4;
this.selectionEnd=this.value.length"
27、点击清空文字
artist"
size=14value="
点击清空文字"
onmouseover=this.focus()onfocus=this.select()onclick="
if(this.value==’点击清空文字’)this.value=’’"
点击清空文字
inputname=namesize=11value=点击清空文字onMouseOver=this.focus()onblur="
if(this.value==’’)this.value=’点击清空文字’"
onFocus=this.select()onClick="
if(this.value==’点击清空文字’)this.value=’’"
28、等于标题(title):
id="
aa"
20"
document.getElementById("
).value=document.title;
29、检测IE是否脱机
测试"
onclick="
alert(window.navigator.onLine)"
30、11种刷新按钮的方法
inputtype=buttonvalue=刷新onClick="
location.reload()"
location=location"
location.assign(location)"
document.execCommand(’Refresh’)"
window.navigate(location)"
location.replace(location)"
window.open(’自身的文件’,’_self’)"
inputtype=buttonvalue=刷新onClick=document.all.WebBrowser.ExecWB(22,1)>
OBJECTclassid=CLSID:
8856F961-340A-11D0-A96B-00C04FD705A2height=0id=WebBrowserwidth=0>
formaction="
自身的文件"
inputtype=submitvalue=刷新>
aid=a1href="
/a>
a1.click()"
31、
ahref="
#"
onClick=document.execCommand("
open"
)>
打开<
32、
aonclick="
window.open(’i001.htm’,’’,’height=300,width=300,resizable=no,location=net’);
href="
打开指定大小网页<
33、
onClick=location.replace("
+location)>
使用记事本编辑<
34、
saveAs"
另存为<
35、
print"
打印<
36、
ahref=mailto:
429752806@>
发送E-mail<
37、
selectAll"
全选<
38、
onClick=location.reload()>
刷新1<
39、
onClick=history.go(0)>
刷新2<
40、
查看源文件<
41、
onClick=window.open(document.location,"
url"
fullscreen"
全屏显示<
42、
onClick=window.external.showBrowserUI("
PrivacySettings"
null)>
internet选项<
43、
oncontextmenu="
window.open(this.href);
returnfalse;
单击右键将在新窗口中打开<
44、
onClick=history.go
(1)>
前进1<
onClick=history.forward()>
前进2<
onClick=history.go(-1)>
后退1<
onClick=history.back()>
后退2<
45、
OrganizeFavorites"
整理收藏夹<
SPANonClick="
window.external.addFavorite(’点’)"
style="
CURSOR:
hand"
title=网页特效站点>
加入收藏<
/SPAN>
window.external.addFavorite(’
window.external.AddFavorite(’’网页特效站点’)"
点击加入收藏夹<
onmouseover="
window.external.addFavorite(’效站点’)"
target="
_self"
>
鼠标感应收藏本站<
this.style.behavior=’url(#default#homepage)’;
this.setHomePage(’target="
鼠标感应设为首页<
46、
window.close()"
关闭窗口<
onClick=window.close();
returnfalse)>
onClick=setTimeout(window.close(),3000)>
3秒关闭本窗口<
functionshutwin(){
window.close();
return;
shutwin();
关闭本窗口<
47、<
varstrHref=window.location.href;
this.setHomePage(’style="
设为首页<
48、等于标题栏:
document.write(document.title);
49、
void(0);
onClick=’window.external.AddFavorite(location.href,document.title);
’>
收藏本页<
window.external.AddFavorite(document.location.href,document.title)"
ahref=javascript:
window.external.addChannel("
typhoon.cdf"
加入频道<
50、
i003.htm"
ondblclick="
window.open(’i003.htm’);
双击打开链接<
51、
style>
#closea:
hover{background:
url(javascript:
window.opener=0;
window.close());
/style>
divid=close>
/div>
52、
AHREF="
void(0)"
onMouseover="
alert(’对不起,禁止选中!
’)"
链接禁止<
/A>
53、滚动条在左侧,将<
html>
改为<
HTMLDIR="
RTL"
54、网页半透明
bodystyle="
filter:
Alpha(Opacity=50)"
55、随机选择背景色
body>
document.body.style.background=(["
red"
blue"
pink"
navy"
gray"
yellow"
green"
purple"
])[parseInt(Math.random()*8)];
56、框架页中不显示滚动条:
SCRIPT>
self.moveTo(0,0)
self.resizeTo(screen.availWidth,screen.availHeight)
/SCRIPT>
57、防止网页被框架
SCRIPTLANGUAGE=JAVASCRIPT>
if(top.location!
==self.location){
top.location=self.location;
58、永远都会带着框架
scriptlanguage="
javascript"
!
--
if(window==top)top.location.href="
frame.htm"
//frame.htm为框架网页
//-->
59、窗口自动最大化
JavaScript"
//-->
60、打开窗口自动最大化
onreadystatechang
- 配套讲稿:
如PPT文件的首页显示word图标,表示该PPT已包含配套word讲稿。双击word图标可打开word文档。
- 特殊限制:
部分文档作品中含有的国旗、国徽等图片,仅作为作品整体效果示例展示,禁止商用。设计者仅对作品中独创性部分享有著作权。
- 关 键 词:
- 简单 js 实例 代码 网页