zoukankan
html css js c++ java
js入门·对象的综合练习(重点介绍Link对象)
1:页面载入时改变状态栏文字;
2:指向链接时改变状态栏文字;
3:打印出当前窗口的URL
4:统计本页上有多少个连接
5:利用伪链接做些类似按钮的事件(例如按了链接一,链接二的指向就改变)
<%
@LANGUAGE
=
"
JAVASCRIPT
"
CODEPAGE
=
"
936
"
%>
<!
DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"
>
<
html
xmlns
="http://www.w3.org/1999/xhtml"
>
<
head
>
<
meta
http-equiv
="Content-Type"
content
="text/html; charset=gb2312"
/>
<
title
>
对象的综合练习(重点介绍Link对象)
</
title
>
<
script
language
="javascript"
>
window.status
=
"
本演示是本章的一个综合练习
"
;
//
这句写在了状态栏
function
linkk()
{
if
(confirm(
"
是否转去天轰穿的教程博客
"
))
{
location.href
=
"
http://thcjp.cnblogs.com/
"
;
}
}
function
gai()
{
if
(confirm(
"
下面我们将后面这个连接指向该下,所以请先看清楚最后一个链接的指向\n\t没看清楚就取消,看清楚了就确定
"
))
{
document.links[
2
].href
=
"
#
"
;
}
}
</
script
>
<
style
type
="text/css"
>
<!--
.STYLE1
{
}
{
color
:
#FF0000
;
font-weight
:
bold
;
}
-->
</
style
>
</
head
>
<
body
>
<
h1
class
="STYLE1"
><
a
href
="javascript:void linkk()"
onmouseover
="window.status='一个关于链接的传说';return true;"
>
这是一个关于对象的综合演示
</
a
></
h1
>
<
p
>
<
script
language
="javascript"
>
var
name
=
prompt(
"
请输入您的名字
"
,
""
);
document.write(
"
本页的完整地址是:
"
+
location.href
+
"
,亲爱的
"
+
name);
</
script
>
对了,这里顺便说下,LINK对象也可以用 document.links.length 这样的方法访问!为了演示方便,我们在弄个链接
</
p
>
<
p
><
a
href
="javascript:void gai()"
>
天轰穿
</
a
>
<
a
href
="http://www.hc115.com/"
>
田洪川
</
a
></
p
>
<
p
>
本页共
<
script
>
document.write(document.links.length)
</
script
>
个链接
</
p
>
</
body
>
</
html
>
查看全文
相关阅读:
第五次作业
第四次作业
第三次作业
第二次作业
2013551822第一次作业
第八次作业
第七次作业
第六次作业
第五次作业
第四次作业
原文地址:https://www.cnblogs.com/thcjp/p/471277.html
最新文章
第一章 《计算机系统漫游》
Ubuntu安装Wildfly(原JBoss)并为其配置MySQL分布式数据源
eclipse安装hibernate-Tools
Ubuntu配置Tomcat9非root用户启动
Mysql在windows系统下的配置
JSTL标签库
配置linux服务器的一些操作
数据库连接池
Linux系统学习优缺点
第八周作业
热门文章
第七周作业
第六周作业
第五周作业
第四周作业
第三周作业
第二周作业
构建之法第一周作业
第八次作业
第七次作业
第六次作业
Copyright © 2011-2022 走看看