• 博客园logo
  • 会员
  • 众包
  • 新闻
  • 博问
  • 闪存
  • 赞助商
  • HarmonyOS
  • Chat2DB
    • 搜索
      所有博客
    • 搜索
      当前博客
  • 写随笔 我的博客 短消息 简洁模式
    用户头像
    我的博客 我的园子 账号设置 会员中心 简洁模式 ... 退出登录
    注册 登录

奋斗中...

曾经的程序员。ASP.NET/C#, JavaScript, PL/SQL, T-SQL; 工具: VS2003/2005, Oracle, SQLServer; 偶尔写点CSS, 批处理.
头脑中经常有新想法, 可惜没有去实现.
Never give up.
Never get into a fight with a pig. Both of you will get dirty. But the pig actually enjoys it.
  • 博客园
  • 联系
  • 订阅
  • 管理

公告

View Post

[JavaScript]获取网页中选中部分的源代码

转载自from: http://topic.csdn.net/u/20090109/21/70c206df-bfc9-4f11-b3d2-4b99b2471e2b.html

function Gethtmlcode() {
    var rng=null,html="";
    if (window.document.selection && window.document.selection.createRange){
            rng=window.document.selection.createRange();
            html=rng.htmlText;
    }else if (window.getSelection){
            rng=window.getSelection();
            if (rng.rangeCount > 0 && window.XMLSerializer){
                    rng=rng.getRangeAt(0);
                    html=new XMLSerializer().serializeToString(rng.cloneContents());
            }
    }

posted on 2011-01-22 23:14  jes  阅读(464)  评论(0)    收藏  举报

刷新页面返回顶部
 
博客园  ©  2004-2025
浙公网安备 33010602011771号 浙ICP备2021040463号-3