0

我想把

<div id='gallerysharebar'>
    <div id='fbshare' class='fb-like' data-href='http://www.facebook.com' data-send='false' data-layout='button_count' data-width='100' data-show-faces='false' data-font='tahoma'>
    </div>
    <a id='pinterest-icon' href='
javascript:void((function(){var e=document.createElement('script');e.setAttribute('type','text/javascript');e.setAttribute('charset','UTF-8');e.setAttribute('src','http://assets.pinterest.com/js/pinmarklet.js?r='+Math.random()*99999999);document.body.appendChild(e)})());
'><img onclick='doPinIt();' src='/wp-content/themes/bliss/images/pin-it.png' alt='Pin It'/></a>
</div>

这段代码在 xxx 部分的 javascript 代码中。问题是代码都是javascript,所以当我直接输入上面的代码时,它会使画廊崩溃。

   f.fn.tn3.version = "1.1.0.44";
    f.fn.tn3.config = {
        data: null,
        skin: null,
        skinDir: "skins",
        skinDefault: '..........<div class="tn3-show-albums"></div><div class="tn3-next-page"></div><div class="tn3-prev-page"></div>**xxxxxxxx**<div class="tn3-play"></div>...........',
        cssID: null
    };
4

1 回答 1

1

我现在明白了。您的引号('vs. ")有问题。你在你的 skinDefault 字符串中使用了单引号,所以一旦你粘贴到上面的 html 中,它就会结束字符串,并且你会从第一个单引号之后的东西中得到一个解析错误。因此,要解决此问题,请将 html 中的所有单引号替换为双引号。请让我知道这是否有效,如果无效,您会看到什么错误。

编辑: 我很确定属性内的引号不起作用,您需要将它们替换为&quot;. 无论哪种方式,请先按原样尝试,然后如果您认为需要,请告诉我&quot;,我会更新我的答案。

<div id="gallerysharebar">
    <div id="fbshare" class="fb-like" data-href="http://www.facebook.com" data-send="false" data-layout="button_count" data-width="100" data-show-faces="false" data-font="tahoma">
    </div>
    <a id="pinterest-icon" href="javascript:void((function(){var e=document.createElement("script");e.setAttribute("type","text/javascript");e.setAttribute(\"charset\",\"UTF-8");e.setAttribute("src","http://assets.pinterest.com/js/pinmarklet.js?r="+Math.random()*99999999);document.body.appendChild(e)})());">
        <img onclick="doPinIt();" src="/wp-content/themes/bliss/images/pin-it.png" alt="Pin It"/>
    </a>
</div>
于 2012-05-31T19:41:00.497 回答