javascript:(
function(){
window.twttr = window.twttr || {};
var D = 550,
A = 450,
C = screen.height,
B = screen.width,
H = Math.round((B/2)-(D/2)),
G = 0,
F = document,
E;
if (C > A) {
G = Math.round((C/2) - (A/2))
}
window.twttr.shareWin = window.open(
'http://twitter.com/share?text=test+e(l.href)+'&t='+e(d.title)','','left='+H+',top='+G+',width='+D+',height='+A+',personalbar=0,toolbar=0,scrollbars=1,resizable=1');
E = F.createElement('script');
F.getElementsByTagName('head')[0].appendChild(E)
}());
这是代码,它应该打开twitter推文窗口,里面必须填充页面的url。然而,当用作谷歌浏览器中的按钮时,它什么都不做,并且通过从javascript中删除“?text =”,我得到了一个空白的推文页面,这不是我想要的。 那怎么能解决它所以它写下网址和标题?像这样: 标题 - 网址
Text的网址代码是“?text =”
提前感谢。
答案 0 :(得分:1)
你错过了一个结束撇号:
'http://twitter.com/share?text=test'
修复整个代码段:
javascript:(function(){window.twttr=window.twttr||{};var D=550,A=450,C=screen.height,B=screen.width,H=Math.round((B/2)-(D/2)),G=0,F=document,E;if(C>A){G=Math.round((C/2)-(A/2))}window.twttr.shareWin=window.open('http://twitter.com/share?text=test'+e(l.href)+'&t='+e(d.title)','','left='+H+',top='+G+',width='+D+',height='+A+',personalbar=0,toolbar=0,scrollbars=1,resizable=1');E=F.createElement('script');F.getElementsByTagName('head')[0].appendChild(E)}());
漂亮的代码:
javascript:(
function(){
window.twttr = window.twttr || {};
var D = 550,
A = 450,
C = screen.height,
B = screen.width,
H = Math.round((B/2)-(D/2)),
G = 0,
F = document,
E;
if (C > A) {
G = Math.round((C/2) - (A/2))
}
window.twttr.shareWin = window.open(
'http://twitter.com/share?text=test'+e(l.href)+'&t='+e(d.title)','','left='+H+',top='+G+',width='+D+',height='+A+',personalbar=0,toolbar=0,scrollbars=1,resizable=1');
E = F.createElement('script');
F.getElementsByTagName('head')[0].appendChild(E)
}());