本帖最后由 cde32 于 2014-02-06 15:18:20 编辑

解决方案 »

  1.   

    <!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>
    <script language="javascript">
    var wenan="文字变量";
    var wangzhi="http://share.baidu.com/static/web/img/imagesharepreview.jpg";function baidu(){
    parent.document.getElementById('L1').innerHTML='<div class="bdsharebuttonbox"><a href="#" class="bds_more" data-cmd="more">分享到:</a><a href="#" class="bds_qzone" data-cmd="qzone" title="分享到QQ空间">QQ空间</a><a href="#" class="bds_tsina" data-cmd="tsina" title="分享到新浪微博">新浪微博</a><a href="#" class="bds_tqq" data-cmd="tqq" title="分享到腾讯微博">腾讯微博</a><a href="#" class="bds_renren" data-cmd="renren" title="分享到人人网">人人网</a><a href="#" class="bds_weixin" data-cmd="weixin" title="分享到微信">微信</a></div>';

    parent._bd_share_config = {
    "common" : {
    "bdSnsKey" : {
    "tsina" : "123456",
    "tqq" : "33333"
    },
    "bdText" : "文案",
    "bdMini" : "2",
    "bdMiniList" : false,
    "bdPic" : "图片网址",
    "bdStyle" : "0",
    "bdSize" : "16"
    },
    "share" : {
    "bdSize" : 16
    },
    "image" : {
    "viewList" : [ "qzone", "tsina", "tqq", "renren", "weixin" ],
    "viewText" : "分享到:",
    "viewSize" : "16"
    },
    "selectShare" : {
    "bdContainerClass" : null,
    "bdSelectMiniList" : [ "qzone", "tsina", "tqq", "renren",
    "weixin" ]
    }
    };
    with (parent.document)
    0[(getElementsByTagName("head")[0] || body)
    .appendChild(createElement("script")).src = "http://bdimg.share.baidu.com/static/api/js/share.js?v=89860593.js?cdnversion="
    + ~(-new Date() / 36e5)];
    }
    </script>
    <button onclick="baidu()">加载</button>
    </body>
    </html>
      

  2.   

    太感谢了
    原来eval()是画蛇添足!
    而且,一直以为是转义符出的问题,但是仔细对照的你的代码,原来还应该在原有代码加上两个parent!!
    我太菜了,系统学习js很有必要啊!