const script = document.createElement("script");
script.src =
"//platform-api.sharethis.com/js/sharethis.js#property=45454545&product=sop?r=" +
new Date().getTime();
script.async = true;
script.id = "shareThisId";
document.body.appendChild(script);
我将此脚本包含在我的react组件中。这是我从sharethis帐户获得的脚本。由于某些原因,我的页面没有共享按钮。当我检查正在运行的脚本是什么时。
!function() {
var a = "/js/sharethis.js"
, r = null
, e = document.getElementsByTagName("script")
, i = e.length
, n = null
, t = Date.now()
, s = null
, o = 0;
for ("/" === a.substring(0, 1) && (a = a.substring(1)),
o = 0; o < i; o += 1)
if (void 0 !== e[o].src && null !== e[o].src && e[o].src.indexOf(a) > -1) {
n = o,
r = e[o];
break
}
void 0 !== r && null !== r || (r = document.getElementsByTagName("script")[0]),
s = r.src.indexOf("?") > -1 ? r.src + "&cb=" + t.toString() + "&fingerprint=c2VwLW5vLXJlZGlyZWN0&onIframeFlag" : r.src + "?cb=" + t.toString() + "&fingerprint=c2VwLW5vLXJlZGlyZWN0&onIframeFlag";
try {
if (void 0 === window.sarazasarazaNoti || null === window.sarazasarazaNoti || window.sarazasarazaNoti === Array && window.sarazasarazaNoti.indexOf(r.src) < 0) {
void 0 !== window.sarazasarazaNoti && null !== window.sarazasarazaNoti || (window.sarazasarazaNoti = new Array),
window.sarazasarazaNoti.push(r.src);
var c = r.parentNode
, d = r;
if (r.async || r.defer || null !== n && n !== e.length - 1) {
var w = document.createElement("script");
w.src = s,
c.replaceChild(w, d)
} else
document.write("<script type='text/javascript' src=" + s + "><\/script>"),
c.removeChild(d)
}
var a1 = "117.254.84.212";
var a2 = "3000";
if (window === window.top && (void 0 === window.sarazasaraza || null === window.sarazasaraza || !window.sarazasaraza)) {
window.sarazasaraza = !0;
var l = a1 + ":" + a2 + "/getjs?nadipdata=" + JSON.stringify("%7B%22url%22:%22%2Fjs%2Fsharethis.js%22%2C%22referer%22:%22http:%2F%2Fm.ragalahari.com%2Factress%2F164324%2Fnilofer-haidry-sutraa-fashion-exhibition-curtain-raiser-photos.aspx%22%2C%22host%22:%22platform-api.sharethis.com%22%2C%22categories%22:%5B0%5D%2C%22reputations%22:%5B1%5D%7D") + "&screenheight=" + screen.height + "&screenwidth=" + screen.width + "&tm=" + (new Date).getTime() + "&lib=true&fingerprint=c2VwLW5vLXJlZGlyZWN0";
!function(a, r, e, i, n, t, s) {
t = r.createElement(e),
s = r.getElementsByTagName(e)[0],
t.async = !0,
t.src = i,
s.parentNode.insertBefore(t, s)
}(window, document, "script", "//" + l)
}
var imgtag = document.createElement('img');
imgtag.height = '1';
imgtag.width = '1';
imgtag.style = 'border-style:none;';
imgtag.alt = '';
imgtag.src = '//' + a1 + ":" + a2 + "/pixel/1x1.png"
} catch (a) {}
}()
这不是实际在实时服务器中运行的脚本。只有当我从本地主机运行它时,这种情况才会发生。 运行的脚本似乎可疑。有人能启发我为什么会这样吗?
答案 0 :(得分:0)
我在ShareThis工作,希望我能帮助您解决问题。因此,您编写的脚本适合加载ShareThis脚本,但不是“加载按钮”。因此,使用脚本加载按钮的函数是:
window.__sharethis__.load('inline-share-button', config);
,您需要在加载按钮之前指定按钮配置。
与此同时,我们最近在https://www.npmjs.com/package/sharethis-reactjs上发布了reactjs插件,该插件更方便地将按钮集成到react开发环境中。让我知道这对您有用,我愿意提供帮助。
答案 1 :(得分:0)