有一个编辑器想添加插入图片功能,点击插入自动打开一个百度图片搜索,点击图片即可获取图片到编辑器,能实现吗?

解决方案 »

  1.   

    已经成功了<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" 
    http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head>
        <title>jquery获取json数据演示页面</title>
        <script type="text/javascript" src="http://www.oschina.net/js/2011/jquery-1.5.1.min.js"></script>

    <style>img{width:100px;}
    p{float:left;}</style>

        <script type="text/javascript"> jQuery.ajax({
    url: 'http://image.baidu.com/i?tn=baiduimagejson&word=美女 ',
    type: 'POST',
    dataType: 'jsonp',
    scriptCharset: 'GBK',
    success: function(data, textStatus, xhr) {
    var html="", i=0;
    jQuery.each(data.data, function(index, val) {
    title          = val.fromPageTitleEnc;
    titleNoFormatting = val.fromPageTitle;
    picUrl         = val.middleURL;  //百度缓存图片
    itemUrl        = val.objURL;    //图片地址
    originalContextUrl= val.fromURLHost;    //网页地址
    unescapedUrl   = val.objURL;    //图片地址
    html += '<p><img src="' + itemUrl + '"/><br/>'+originalContextUrl+'<br/></p>';
    i++;

    if(i >= 628) return false;
    });

    $('#list').after(html);

    },
    error: function(xhr, textStatus, errorThrown) {
    //called when there is an error
    }
    });

        </script>
    </head>
    <body>
        <input id="Button1" type="button" value="获取数据" onclick="getData()" />
       <ul id="list"></ul>
    </body>
    </html>