你对百度页面进行文字选择,立即显示在index的textfieid1 中???

解决方案 »

  1.   

    <%@LANGUAGE="VBSCRIPT" CODEPAGE="936"%>
    <html>
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=gb2312">
    <title>无标题文档</title>
    </head><body>
    <input type="text" id="txt1">
    <iframe src="3.asp"></iframe>
    </body>
    </html><%@LANGUAGE="VBSCRIPT" CODEPAGE="936"%>
    <html>
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=gb2312">
    <title>无标题文档</title>
    <script language="JavaScript">
    document.onmouseup=function()
    {
    if(document.selection.createRange().text!="")
    {
    window.parent.document.getElementById("txt1").value=document.selection.createRange().text;
    }}</script>
    </head><body>
    例如我的页面index.html中一个textfieid1
    和一个iframe   src="www.baidu.com"   子框架
    在子框架中打开了百度页面
    然后选择一段文字 立即在文本框textfieid1 中显示你刚才选中的文字
    这个问题难在 是在子框架页面中选取文字放到父页面的文本框中 
    </body>
    </html>如果没理解错的话
      

  2.   

    要跨域訪問iframe中的內容,只有通過xmlhttp來獲取頁面的內容
    <!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>
        <title>未命名頁面</title>
        
        <script type="text/javascript">
        <!--
        var xmlhttp;
        
        function createHTTP()
        {
            if (window.ActiveXObject)
            {
                xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
            }
            else if (window.XMLHttpRequest)
            {
                xmlhttp = new XMLHttpRequest();
            }
        }
        
        function GetData()
        {
            createHTTP();
            xmlhttp.onreadystatechange = StateChange;
            xmlhttp.open("GET", "http://www.csdn.net", false);
            xmlhttp.send();
        }
        
        function StateChange()
        {
            if (xmlhttp.readystate == 4)
            {
                if (xmlhttp.status == 200)
                {
                    document.getElementById('frame1').contentWindow.document.body.innerHTML = xmlhttp.responseText;
                    document.getElementById('frame1').contentWindow.document.onmouseup = ShowSelection;
                }
            }
        }
        
        function ShowSelection()
        {
            var selection = document.getElementById('frame1').contentWindow.document.selection;
            document.getElementById('txtShow').value = selection.createRange().text;
        }
        
        //-->
        </script>
        
    </head>
    <body onload="GetData()">
        <input type="text" id="txtShow" style="width:400px" />
        <div>
            <iframe width="100%" height="100%" id="frame1">
            </iframe>
        </div>
    </body>
    </html>
      

  3.   

    这个问题难在 是在子框架页面中选取文字放到父页面的文本框中 
    parent.document........
    top.document.........
      

  4.   

    要跨域訪問iframe中的內容,只有通過xmlhttp來獲取頁面的內容
    ==================================================
    可用服务端的一个专门的页面来抓取
    如:GetResponse.asp?url=www.baidu.com
    在GetResponse.asp里用服务端脚本vbscript的xmlhttp来抓取这样可解决跨域
      

  5.   

    问题难点在于
    document.selection.createRange()
    只可以获取textarea文本内得选取内容
      

  6.   

    首先非常感谢TNT_1st_excellence
    耽误了您的时间!现在的问题是打开百度页面 是能够被选取
    但是百度的二级页面跳转出去了
    怎么能够获取二级别页面的所选中内容呢
      

  7.   

    用下面的两个方法会有什么问题:parent.all.item('P_id')=document.all.item('Sub_id')document.frames.my_iframe.document.all.my_textarea.text
      

  8.   

    大家有没有注意在子框架iframe中显示innerhtml读出来的网站出现乱码情况
    不知道怎么回事
    向google没有乱码
    其他都是乱码在iframe中显示