| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 2492 人关注过本帖
标题:想用一个本地html文件中的一个按钮获得远程地址中的内容,尝试了httpReques ...
只看楼主 加入收藏
wanguhssheng
Rank: 2
等 级:论坛游民
威 望:2
帖 子:131
专家分:24
注 册:2016-2-26
结帖率:79.17%
收藏
 问题点数:0 回复次数:1 
想用一个本地html文件中的一个按钮获得远程地址中的内容,尝试了httpRequest和frames都不行,貌似遇到了同源问题,请大侠帮忙。
如网址:http://www.
搜索更多相关主题的帖子: 本地 远程 地址 内容 尝试 
2018-08-22 10:41
wanguhssheng
Rank: 2
等 级:论坛游民
威 望:2
帖 子:131
专家分:24
注 册:2016-2-26
收藏
得分:0 
<!DOCTYPE HTML>
<html>
    <head>
        <title>指定网址,获得内容</title>
        <link rel = "stylesheet" type = "text/css" href = "mystyle.css"></link>
        <style>
            #pannel{
                color:red;
            }
        </style>
    <head>
    <body>
        <script>
            var httpRequest = new XMLHttpRequest();
            function getfromnet(){
                var url = document.getElementById("theurl").value;
                alert(url);
                //var httpRequest = new XMLHttpRequest();
                httpRequest.onreadystatechange = handleResponse;
                httpRequest.open("GET", url);
                httpRequest.send();
                sleep(1000);
            }

            function handleResponse(){
                alert("here");
                alert(httpRequest.responseText);
            }

        </script>
        <div id = pannel style="border: medium maroon dashed;width:31em;">
            <p style="font-size:2rem"><h3>请输入目标网址:</h3></p>
            <input type = "textarea" placeholder = "http://10.0.4.87:8080/tisco/login.html#reloaded"
            id = theurl  
            value = "http://10.0.4.87:8080/tisco/login.html#reloaded"
            style = "text-decoration:underline;background:yellow;color:red;padding:2px;width:30em">
            </input>
            <p/>
            <input type = "submit" onclick = "getfromnet()"></input>
        </div>
        <a  href = "http://oa.(page)/tisconew">OA</a>
    </body>
</html>
2018-08-22 11:02
快速回复:想用一个本地html文件中的一个按钮获得远程地址中的内容,尝试了httpR ...
数据加载中...
 
   



关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.016823 second(s), 9 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved