Using current url in a javascript function
This question already has an answer here:
window.location.href
contains the current URL of the page.
So your function should look like this:
function twitterShare(){
window.open('http://twitter.com/intent/tweet?text=Check this out here: ' + window.location.href,
"twitterWindow", "height=380,width=660,resizable=0,toolbar=0,menubar=0,status=0,location=0,scrollbars=0")
return false;
}
You can use window.location.href
. It holds the value of the current page you are on.
下一篇: 在javascript函数中使用当前网址