本帖最后由 fansart 于 2012-08-10 16:08:57 编辑

解决方案 »

  1.   

          我没有实现过。但是我想关键是获取对象。比如<div id="picture"><img src="http://........"/></div>。如果能获取该对象就能获取到SRC,也就能直接显示出来了。而这个如果无法通过选区来获取。这种想法也就无法实现。不过我不明白为什么你一定要用选区来达到获取呢?单击或者mouseover不可以?或者你有其他什么特别的需求?
      

  2.   

    只兼容IE<!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>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <title>宝宝年步龄几岁几月几天</title>
    </head>
    <body>
    <div id="show" style="background:#f60;color:#fff;"></div>
    <div id="tst" onMouseUp="iset(getSelectText())">
    <p>记得以前篱笆网以前是生成动态的生日提醒图片,后来自己决定给自己宝宝做一个。但是一直都没空去弄,最近比较空所以做了,其实做的时候主要是PNG与图片(任何格式jpg,gif,bmp)的重叠与文字写入最后生成图片PNG!,用到了计算年宝宝生日年龄的计算细到几岁几月几天下面会介绍方法getAge!文章末尾附下载地址</p>
    <p>效果图如下:</p>
    <p>图1:(画布)<br />
    <img alt="画布" title="画布" src="http://i1173.photobucket.com/albums/r595/charrysong/upload/baobaoage1.jpg" style="width: 482px; height: 250px"/>
    </p>
    <p>图2:(我把它叫遮罩层)<br />
    <img alt="遮罩" title="遮罩层" src="http://i1173.photobucket.com/albums/r595/charrysong/upload/baobaoage2.jpg" style="width: 482px; height: 250px"/>
    </p>
    <p>当然图片一定必须是PNG这样才能让宝宝的照片显示出来!</p>
    <p>好了贴代码了!</p>
    <p>前台代码:</p>
    好了已经写完了,源码分享下!<a href="http://www.ok22.org/download/baobaoPNG.zip" title="下载地址" target="_blank">下载地址</a>
    <p>提醒:</p>
    <blockquote>
    <p>
         如果遇到GDI+中发生一般性错误<br />
            方法1、img文件夹不要建立程序会自己建立的(我是这么实现的)<br />
            方法2、解决办法如下:<a href="http://www.ok22.org/art_detail.aspx?id=403" target="_blank" title=".net中 GDI+ 中发生一般性错误 解决办法">.net中 GDI+ 中发生一般性错误 解决办法</a>
        </p>
    </blockquote>
    this is test.hello!你好么,我很好</div>
    <script>
        function getSelectText(){
    if (window.getSelection){  // mozilla FF
    return window.getSelection();
    }else if (document.getSelection){
    return document.getSelection();
    }else if (document.selection){  //IE
    return document.selection.createRange().htmlText;
    }
        }
    function iset(value)
    {
    document.getElementById('show').innerHTML=value;
    }
    </script>
    </body>
    </html>