利用javascript窗口框架做的判断ip地址合法性并将其分类
2008-12-11 13:42
661 查看
6.html
<html>
<head>
<title>frame get Value test</title>
<script type="text/javascript">
function checkIP()
{
var IP=document.getElementById("txtFather").value;
document.write("<h1>The IP Address:</h1>")
document.write(IP);
var lastip;
lastip=IP.split("."); //Use. Ip to separate
if(parseInt(lastip[0])<=126) //First determine the scope of the ip address
{
if(parseInt(lastip[0])==10)
{
document.write(" is private Address!");
}
else
{
document.write("is belong to the A class of address!");
}
}
else
{
if(parseInt(lastip[0])==127)
{
document.write(" is the address of the LookBack!");
}
else
{
if(parseInt(lastip[0])<=191)
{
document.write("Belong to the B category of address!");
}
else
{
if(parseInt(lastip[0])<=223)
{
if(parseInt(lastip[0])==192&&parseInt(lastip[1]==168))
{
document.write(" is private Address!");
}
else
{
document.write("Belong to the C category of address!");
}
}
else
{
if(parseInt(lastip[0])<=239)
{
document.write("is belong to the D class of Address!");
}
else
{
document.write(" is belong to the E class of Address!");
}
}
}
}
}
}
</script>
</head>
<iframe frameborder="1" height="50%" marginheight="0" marginwidth="0" scrolling="no" width="100%" src="7.html"></iframe>
<h3>this is theResult text</h3>
<input type="text" name="txtFather" id="txtFather"/>
<input type="button" name="btnFather" id="btnFather" value="CheckClass" onclick="checkIP();" />
</html>
7.html
<html>
<head>
<title>the son frame</title>
<body bgcolor="#F0F7FF" text="#FF0000">
<p align="center"><b>
<script type="text/javascript">
function setValue()
{
var ip=document.getElementById("txtSon").value;
var exp=/^(/d{1,2}|1/d/d|2[0-4]/d|25[0-5])/.(/d{1,2}|1/d/d|2[0-4]/d|25[0-5])/.(/d{1,2}|1/d/d|2[0-4]/d|25[0-5])/.(/d{1,2}|1/d/d|2[0-4]/d|25[0-5])$/;
var reg=ip.match(exp);
var ErrMsg="You enter the IP address is illegal, it is the right format/nIP:xxx.xxx.xxx.xxx(xxxIn the range of between0-255)"
var Msg="You enter the IP address is legitimate!"
if(reg==null)
{
alert(ErrMsg);
}
else
{
alert("ip value:"+ip);
parent.document.getElementById("txtFather").value=ip;
}
}
todayDate=new Date();
date=todayDate.getDate();
month=todayDate.getMonth() +1;
year=todayDate.getYear();
document.write("Today is")
document.write("<br>")
if(navigator.appName=="Netscape")
{
document.write(1900+year);
document.write("/");
document.write(month);
document.write("/");
document.write(date);
document.write(" ");
document.write("<br>")
}
if(navigator.appVersion.indexOf("MSIE") != -1)
{
document.write(year);
document.write("/");
document.write(month);
document.write("/");
document.write(date);
document.write(" ");
document.write("<br>")
}
if (todayDate.getDay() == 5) document.write("Friday")
if (todayDate.getDay() == 6) document.write("saturday")
if (todayDate.getDay() == 0) document.write("sunday")
if (todayDate.getDay() == 1) document.write("monday")
if (todayDate.getDay() == 2) document.write("tuesday")
if (todayDate.getDay() == 3) document.write("wednesday")
if (todayDate.getDay() == 4) document.write("thursday")
</script>
</head>
<br>
<font color="#0080ff"><blink><b><h3 align="center">This is IP text and button</h3></b></blink> </font>
<input type="text" name="txtSon" id="txtSon" /><br>
<input type="button" name="btnSon" id="btnSon" value="Submit" onclick="setValue();" />
</b></p>
</body>
</html>
运行结果正确!
<html>
<head>
<title>frame get Value test</title>
<script type="text/javascript">
function checkIP()
{
var IP=document.getElementById("txtFather").value;
document.write("<h1>The IP Address:</h1>")
document.write(IP);
var lastip;
lastip=IP.split("."); //Use. Ip to separate
if(parseInt(lastip[0])<=126) //First determine the scope of the ip address
{
if(parseInt(lastip[0])==10)
{
document.write(" is private Address!");
}
else
{
document.write("is belong to the A class of address!");
}
}
else
{
if(parseInt(lastip[0])==127)
{
document.write(" is the address of the LookBack!");
}
else
{
if(parseInt(lastip[0])<=191)
{
document.write("Belong to the B category of address!");
}
else
{
if(parseInt(lastip[0])<=223)
{
if(parseInt(lastip[0])==192&&parseInt(lastip[1]==168))
{
document.write(" is private Address!");
}
else
{
document.write("Belong to the C category of address!");
}
}
else
{
if(parseInt(lastip[0])<=239)
{
document.write("is belong to the D class of Address!");
}
else
{
document.write(" is belong to the E class of Address!");
}
}
}
}
}
}
</script>
</head>
<iframe frameborder="1" height="50%" marginheight="0" marginwidth="0" scrolling="no" width="100%" src="7.html"></iframe>
<h3>this is theResult text</h3>
<input type="text" name="txtFather" id="txtFather"/>
<input type="button" name="btnFather" id="btnFather" value="CheckClass" onclick="checkIP();" />
</html>
7.html
<html>
<head>
<title>the son frame</title>
<body bgcolor="#F0F7FF" text="#FF0000">
<p align="center"><b>
<script type="text/javascript">
function setValue()
{
var ip=document.getElementById("txtSon").value;
var exp=/^(/d{1,2}|1/d/d|2[0-4]/d|25[0-5])/.(/d{1,2}|1/d/d|2[0-4]/d|25[0-5])/.(/d{1,2}|1/d/d|2[0-4]/d|25[0-5])/.(/d{1,2}|1/d/d|2[0-4]/d|25[0-5])$/;
var reg=ip.match(exp);
var ErrMsg="You enter the IP address is illegal, it is the right format/nIP:xxx.xxx.xxx.xxx(xxxIn the range of between0-255)"
var Msg="You enter the IP address is legitimate!"
if(reg==null)
{
alert(ErrMsg);
}
else
{
alert("ip value:"+ip);
parent.document.getElementById("txtFather").value=ip;
}
}
todayDate=new Date();
date=todayDate.getDate();
month=todayDate.getMonth() +1;
year=todayDate.getYear();
document.write("Today is")
document.write("<br>")
if(navigator.appName=="Netscape")
{
document.write(1900+year);
document.write("/");
document.write(month);
document.write("/");
document.write(date);
document.write(" ");
document.write("<br>")
}
if(navigator.appVersion.indexOf("MSIE") != -1)
{
document.write(year);
document.write("/");
document.write(month);
document.write("/");
document.write(date);
document.write(" ");
document.write("<br>")
}
if (todayDate.getDay() == 5) document.write("Friday")
if (todayDate.getDay() == 6) document.write("saturday")
if (todayDate.getDay() == 0) document.write("sunday")
if (todayDate.getDay() == 1) document.write("monday")
if (todayDate.getDay() == 2) document.write("tuesday")
if (todayDate.getDay() == 3) document.write("wednesday")
if (todayDate.getDay() == 4) document.write("thursday")
</script>
</head>
<br>
<font color="#0080ff"><blink><b><h3 align="center">This is IP text and button</h3></b></blink> </font>
<input type="text" name="txtSon" id="txtSon" /><br>
<input type="button" name="btnSon" id="btnSon" value="Submit" onclick="setValue();" />
</b></p>
</body>
</html>
运行结果正确!
相关文章推荐
- 利用HTML+JAVASCRIPT编写的判断IP地址合法性,并将其合法IP地址分类
- 编写一个判断IP地址合法性的bash脚本
- 【用jQuery来判断浏览器的类型】及【javascript获取用户ip地址】
- Linux学习之道:编写一个判断IP地址合法性的bash脚本
- Java:判断IP4地址合法性
- CI框架下利用discuz的IP库将ip转换为省市地址!
- 【用jQuery来判断浏览器的类型】及【javascript获取用户ip地址】
- JavaScript判断窗口是否最小化的代码(跨浏览器)
- 怎么在页面利用javascript判断浏览器的类型
- iphone 电子邮箱的地址 邮箱地址合法性判断功能
- 用javascript 判断IE窗口是否打开
- 第一章 : javaScript框架分类及主要功能
- 巧妙利用三招保护局域网中的 IP 地址
- javascript网页特效——窗口和框架
- 利用JavaScript和正则表达式进行丰富的日期判断
- javaScript验证ip的合法性
- 利用QQWry.dat 实现IP 地址高效检索注意事项
- javascript判断窗口刷新及关闭
- 利用路由修改thinkphp框架开发的后台地址
- qt中使用正则表达式检测ip地址合法性