什么';“这个Javascript有什么问题吗?”;获取URL和标题“;?
这是代码,它应该打开twitter tweet窗口,其中必须填写页面的url。然而,当在google chrome中用作按钮时,它什么也不做,并且通过从javascript中删除“?text=”,我得到了一个空白的推特页面,这不是我想要的。 那么,如何修复它,以便它写下url和标题?这样地: 标题-Url 文本的url代码为“?Text=”什么';“这个Javascript有什么问题吗?”;获取URL和标题“;?,javascript,twitter,bookmarklet,Javascript,Twitter,Bookmarklet,这是代码,它应该打开twitter tweet窗口,其中必须填写页面的url。然而,当在google chrome中用作按钮时,它什么也不做,并且通过从javascript中删除“?text=”,我得到了一个空白的推特页面,这不是我想要的。 那么,如何修复它,以便它写下url和标题?这样地: 标题-Url 文本的url代码为“?Text=” 提前感谢。您缺少一个结束撇号: javascript:( function(){ window.twttr = window.twt
提前感谢。您缺少一个结束撇号:
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)
}());
修复了整个代码段:
'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)
}());