主域名abc.com下面有一个1.html,如何在1.html当中添加js去访问子域名test.abc.com当中2.html当中的元素呢?
我在1.html当中使用:
alert(document.getElementById("qq").document.body.innerHTML);//此时弹出的是1.html当中的源代码,不知道为什么,
请指教
域名:http://abc.com/1.html
<html>
<head>
</head>
<body>
<iframe id="qq" src="http://test.abc.com/2.html"></iframe>
</body>
</html>
我在1.html当中使用:
alert(document.getElementById("qq").document.body.innerHTML);//此时弹出的是1.html当中的源代码,不知道为什么,
请指教
域名:http://abc.com/1.html
<html>
<head>
</head>
<body>
<iframe id="qq" src="http://test.abc.com/2.html"></iframe>
</body>
</html>
在哪里加呢?哪个文件里面加?1.html?加在什么地方,必须回在head里面吗?
就是2.html里面。<script>
document.domain = 'abc.com';
</script>
请问如果子域名,也就是被调用页面(2.html),我没有权限,还有什么办法处理吗?
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
<title>远程加载htm</title>
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js"></script>
<script type="text/javascript">
$(function(){
$("#tt").load("http://test.abc.com/2.html",function(d){alert(d);});
});
</script>
<div id="tt"></div>
先看看能否输出什么!
jQ只不过是js的库,js办不到的jQ同样办不到。
为什么那么多人总是喜欢将jQ神化。