各位高手帮帮忙!javascript得 难题!

xxgchappy 2004-04-29 05:27:34
有一个网页
内容如下
<body>
<script type="text/javascript"
src="http://www.test.com/test.js">
</script>

</body>
里面有这个代码,他的test.js用document.write写了一个frame 进去,frame 在到另外网站下点内容近来,我怎么用javascript得到用frame下的网页内容,我试着innerhtml,outerhtml都只能得到
<script type="text/javascript"
src="http://www.test.com/test.js">
</script>
没有后来下的网页内容!
...全文
93 20 打赏 收藏 转发到动态 举报
写回复
用AI写文章
20 条回复
切换为时间正序
请发表友善的回复…
发表回复
xxgchappy 2004-05-04
  • 打赏
  • 举报
回复
still can not get I want !
dullwolf 2004-05-04
  • 打赏
  • 举报
回复
<TEXTAREA id="online_num" style="width:100%;height:100%" >
</TEXTAREA>
<script language=JavaScript>
getonlinenum();
function getonlinenum()
{
var objXMLHTTP=new ActiveXObject("MICROSOFT.XMLHTTP");
objXMLHTTP.open("GET","http://www.sohu.com",false);
objXMLHTTP.send("");
var strReturn=objXMLHTTP.ResponseText;
online_num.value= strReturn;
}
</script>
dullwolf 2004-05-04
  • 打赏
  • 举报
回复
XMLHTTP
xxgchappy 2004-05-02
  • 打赏
  • 举报
回复
用xml显示,没有权限 ,八成跨域有难题阿!
fhj2050 2004-05-02
  • 打赏
  • 举报
回复
用XML试一试啊
xxgchappy 2004-05-02
  • 打赏
  • 举报
回复
楼上的 这样是得不到真正的内容的,只能得到

<script type="text/javascript"
src="http://www.test.com/test.js">
</script>
全息宇宙 2004-05-02
  • 打赏
  • 举报
回复
用XMLHTTP获取:
<%
on error resume next
Server.ScriptTimeOut=120
url = "Http://www.csdn.net" '新闻来源的页面

wstr = getHTTPPage(url) '取得页面内容
response.write wstr
%>
<%
function getHTTPPage(url)
on error resume next
dim http
set http=Server.createobject("Microsoft.XMLHTTP")
Http.open "GET",url,false
Http.send()
if Http.readystate<>4 then
exit function
end if
getHTTPPage=bytes2BSTR(Http.responseBody)
set http=nothing
if err.number<>0 then err.Clear
end function

Function bytes2BSTR(vIn)
dim strReturn
dim i,ThisCharCode,NextCharCode
strReturn = ""
For i = 1 To LenB(vIn)
ThisCharCode = AscB(MidB(vIn,i,1))
If ThisCharCode < &H80 Then
strReturn = strReturn & Chr(ThisCharCode)
Else
NextCharCode = AscB(MidB(vIn,i+1,1))
strReturn = strReturn & Chr(CLng(ThisCharCode) * &H100 + CInt(NextCharCode))
i = i + 1
End If
Next
bytes2BSTR = strReturn
End Function

Function NewString(wstr,strng)
NewString=Instr(wstr,strng)
End Function
%>
lang11zi 2004-05-02
  • 打赏
  • 举报
回复
up
xxgchappy 2004-05-02
  • 打赏
  • 举报
回复
顶,期盼高手出现!
xxgchappy 2004-04-29
  • 打赏
  • 举报
回复
他动态生成了一个frame,请求sohu.com网页,我就是想在javascript中得到sohu.com得主页内容
---------------------------------------------------
跨域了..

用XMLHTTP实现.


本地,和远程不一样的,你怎么用xmlhttp?
renaski 2004-04-29
  • 打赏
  • 举报
回复
但请教楼上的我本地为什么是可以实现的啊?
莫非我的那个没有跨域?
wanghr100 2004-04-29
  • 打赏
  • 举报
回复
他动态生成了一个frame,请求sohu.com网页,我就是想在javascript中得到sohu.com得主页内容
---------------------------------------------------
跨域了..

用XMLHTTP实现.
52juanjuan 2004-04-29
  • 打赏
  • 举报
回复
代码好像没有问题也
renaski 2004-04-29
  • 打赏
  • 举报
回复
我在本地读取另一个网页的<script>里的内容时是可以的。

1.htm
<script defer>
alert(ren.b)
</script>
<iframe name="ren" id="ren" src="file:///C|/Inetpub/wwwroot/ren/Untitled-2.htm"></iframe>


2.htm
<SCRIPT LANGUAGE="JavaScript">
<!--
b="1aa"
//-->
</SCRIPT>
<div id=b>aaa</div>
renaski 2004-04-29
  • 打赏
  • 举报
回复
不敢保证对。


比方说
写的框架里又引用了a的script变量。

<script defer>
alert(frame_name.a)
</script>
xxgchappy 2004-04-29
  • 打赏
  • 举报
回复
上面的是test.js
他动态生成了一个frame,请求sohu.com网页,我就是想在javascript中得到sohu.com得主页内容
xxgchappy 2004-04-29
  • 打赏
  • 举报
回复
document.write('<ifr' + 'ame' +

' width="0"' +
' height= "0"' +

' src="http://www.sohu.com"' +
' marginwidth="0"' +
' marginheight="0"' +
' vspace="0"' +
' hspace="0"' +
' allowtransparency="true"' +
' scrolling="no">');

document.write('</ifr' + 'ame>');

joe820302 2004-04-29
  • 打赏
  • 举报
回复
应该是得不到的吧,安全性问题
gesnpt 2004-04-29
  • 打赏
  • 举报
回复
可能是js写的用问题,把它贴出来看看,是不是""号的问题!
abcwzl 2004-04-29
  • 打赏
  • 举报
回复
不知道,帮人

87,922

社区成员

发帖
与我相关
我的任务
社区描述
Web 开发 JavaScript
社区管理员
  • JavaScript
  • 无·法
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧