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
>
查看全文
相关阅读:
osx 编译安装配置 ruby on rails
tls/ssl证书生成和格式转换
nginx相关的一些记录
用systemd脚本自动启动node js程序
SSH Tunneling
c代码读取目录信息
用Qt Creator 对 leveldb 进行简单的读写
centos 7 相关的一些记录
发现一段精简的模板算法(非原创)
几个常用的散列算法
原文地址:https://www.cnblogs.com/thcjp/p/471277.html
最新文章
深入浅出Semaphore源码解析
深入浅出ReentrantReadWriteLock源码解析
深入浅出ReentrantLock源码解析
ThreadLocal源码解析
JVM垃圾回收的过程
年前辞职,年后找工作
airport 抓包
配置ssh使用socks代理
配置git使用socks5代理
bash 相关的一些小代码片断
热门文章
MacOS changed System Integrity Protection status
CMakeLists.txt for nginx
构建最小的docker容器
centos 7 挂载大硬盘
rsync 通过 ssh 上传文件
php-fpm 在centos 7下的安装配置
在osx下通过vmware无GUI方式运行centos 7
ruby on rails 在centos 7下的安装配置
Mariadb 在centos 7下的安装配置
PostgreSQL 在centos 7下的安装配置
Copyright © 2011-2022 走看看