我们正在使用AddThis社交分享功能与我们的Sitecore/MVC应用程序。我们面临的问题是LinkedIn分享总是在新窗口中打开。在检查时,我们可以看到代码中的target=_blank,该代码未添加到我们的代码中。
有什么帮助吗?
谢谢, Chandana
有什么帮助吗?
谢谢, Chandana
$(document).ready(function () {
var clickinterval = setInterval(setclickevent, 500);
function setclickevent() {
if ($('.at-svc-linkedin').length > 0) {
$('.at-svc-linkedin').on('click', function () {
window.open('https://www.linkedin.com/sharing/share-offsite/?url=' + fixedEncodeURIComponent(window.location.href), 'popup', 'width=600,height=600');
e.preventDefault();
return false;
});
clearInterval(clickinterval);
}
}
function fixedEncodeURIComponent(str) {
return encodeURIComponent(str).replace(/[!'()*]/g, function (c) {
return '%' + c.charCodeAt(0).toString(16);
});
}
});
我怀疑这是与AddThis社交分享功能有关的问题。要在LinkedIn上分享,您只需要以下URL格式...
https://www.linkedin.com/sharing/share-offsite/?url={url}
然后,您可以根据自己的喜好设置<a href="...">
元素,使用target="_blank"
或不使用。
来源:官方 LinkedIn 分享文档。