TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
C# Corner
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Share Customize Text in Twitter using jQuery
Bhushan Singh
Mar 03
2016
Code
844
0
0
facebook
twitter
linkedIn
Reddit
WhatsApp
Email
Bookmark
expand
<script type=
"text/javascript"
src=
"http://code.jquery.com/jquery-1.7.2.min.js"
></script>
<script type=
"text/javascript"
>
// We bind a new event to our link
$(
'#click_button'
).live(
"click"
, function(e)
{
var twitter_text = $(
"#twitter_text"
).val();
//We tell our browser not to follow that link
e.preventDefault();
//We get the URL of the link
var loc = $(
this
).attr(
'href'
);
//We get the title of the link
var title = encodeURIComponent($(
this
).attr(
'title'
));
//We trigger a new window with the Twitter dialog, in the middle of the page
window.open(
'http://twitter.com/share?url='
+ loc +
'&text='
+ twitter_text +
'&'
,
'twitterwindow'
,
'height=450, width=550, top='
+ ($(window).height() / 2 - 225) +
', left='
+ $(window).width() / 2 +
', toolbar=0, location=0, menubar=0, directories=0, scrollbars=0'
);
});
</script> <textarea rows=
"4"
cols=
"50"
id=
"twitter_text"
>
At w3schools.com you will learn how to make a website.</textarea> <button type=
"button"
id=
"click_button"
>Click Me!</button>
Share Customize Text
jQuery