0

I have this js function

function twitterShare(){
    window.open( 'http://twitter.com/intent/tweet?text='+$(".section-title h1").text() +'         
    '+window.location, "twitterWindow",
    "height=380,width=660,resizable=0,toolbar=0,menubar=0,status=0,location=0,scrollbars=0") 
    return false;
}

When the twitter window opens it grabs the .section-title h1 class, but I need it to say something like this,

"Check this out here: http://currentwebsiteurl.com"

I need a text string then grab the url of the page.

Any help would be greatly appreciated.

Dhaval Marthak
  • 17,246
  • 6
  • 46
  • 68
DevNinja
  • 60
  • 9

2 Answers2

0

You can use window.location.href. It holds the value of the current page you are on.

Jnatalzia
  • 1,687
  • 8
  • 14
0

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;
}
dbanck
  • 250
  • 2
  • 4