想实现的功能:
在js.html当中重写函数:clickSb()
点击:http://www.56dnf.com.cn/ad.html当中的红色div弹出:我在本地
但我的思路不成功,请各位老师指点
//http://127.0.0.1/js.html内容如下:<!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>无标题文档</title>
</head><body></body><iframe src="http://www.56dnf.com.cn/ad.html" ></iframe>
</html>
<script language="javascript">
function clickSb()
{
alert("我在本地");}
</script>
//http://www.56dnf.com.cn/ad.html内容如下:
<!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>无标题文档</title><script language="javascript">
function clickSb()
{
alert("我在远程");}</script>
</head>
<body>
<div onclick="clickSb()" "id="sb" style="width:100px; height:100px; background:red;"></div>
</body>
</html>
在js.html当中重写函数:clickSb()
点击:http://www.56dnf.com.cn/ad.html当中的红色div弹出:我在本地
但我的思路不成功,请各位老师指点
//http://127.0.0.1/js.html内容如下:<!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>无标题文档</title>
</head><body></body><iframe src="http://www.56dnf.com.cn/ad.html" ></iframe>
</html>
<script language="javascript">
function clickSb()
{
alert("我在本地");}
</script>
//http://www.56dnf.com.cn/ad.html内容如下:
<!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>无标题文档</title><script language="javascript">
function clickSb()
{
alert("我在远程");}</script>
</head>
<body>
<div onclick="clickSb()" "id="sb" style="width:100px; height:100px; background:red;"></div>
</body>
</html>
//http://127.0.0.1/js.html内容如下:<!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>无标题文档</title>
</head><body></body><iframe id="f1" src="http://www.56dnf.com.cn/ad.html" onload="on_load()"></iframe>
</html>
<script language="javascript">
document.domain = "56dnf.com.cn";
function on_load(){
window.frames["f1"].clickSb = function()
{
alert("我在本地");
};
}
</script>
//http://www.56dnf.com.cn/ad.html内容如下:
<!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>无标题文档</title><script language="javascript">
function clickSb()
{
alert("我在远程");}
document.domain = "56dnf.com.cn";
</script>
</head>
<body>
<div onclick="clickSb()" "id="sb" style="width:100px; height:100px; background:red;"></div>
</body>
</html>
重写是指在同一页面,或者最后合并在一个页面
比如:
同一页面,下面的a最后弹出2:
<script>
function a(){
alert(1);
}
function a(){
alert(2);
}
</script>合并,就是在一个js文件里写一个函数
然后在html里通过script src=js文件
并在html里重写你这种写法是2个互不相干的页面,哪里来的重写一说?