I'm a javascript novice trying to build a basic share button as a learning project. I'm a bit stumped about one aspect. While I can grab the URL of the current page and pass that into the url that prepopulates the share form, I'm not sure how to grab the html title.
Here's what I have to far:
<a href="http://www.domain.com/submit" onclick="window.location = 'http://www.domain.com/submit?url=' + encodeURIComponent(window.location); return false;"> Share This </a>
What do I add to the onclick section to get the current page's title as well? Whatever it is would be passed as "title=" in the URL.
Bonus: Is there something I can add to send along some highlighted text from the current page? That would go in the URL as "body="
So I'm looking to fill in these blanks:
<a href="http://www.domain.com/submit" onclick="window.location = 'http://www.domain.com/submit?url=' + encodeURIComponent(window.location); return false; + 'title=' + SOMETHING + 'body=' + SOMETHING'"> Share This </a>
At least I think so. I'm not 100% sure I've got the +'s and ''s in the right place.