1

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.

2
  • "it"? Which it? twitter? the new page? Commented Aug 2, 2013 at 15:32
  • Yeah, I looked at that but couldn't figure out how to write the function the right way. Commented Aug 2, 2013 at 15:40

2 Answers 2

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;
}
Sign up to request clarification or add additional context in comments.

Comments

0

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

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.