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
Answers
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Forums
Monthly Leaders
Forum guidelines
rakesh bairi
1.4k
307
3.2k
Highlight selected text and show next time
Sep 23 2011 9:24 AM
I am interested in saving text when user selects any text anywhere on a web page that text has to be highlighted and has to save that text as a string in DataBase.
when same user saw same page next time text has to be highlighted as done previously by him.
If anyone knows a simple elegant way to do this I would really appreciate it, but I'll take any solution at this point. Even if you can point me in the right directions that would be appreciated. Thanks in advance.
I m tried with this code
function highlight() {
var range, sel;
// IE case
if (document.selection && document.selection.createRange) {
range = document.selection.createRange();
//range.execCommand("Bold", false, null);
range.execCommand("BackColor", "false", "yellow");
txt = document.selection.createRange().text;
} else if (window.getSelection) {
// Non-IE
sel = window.getSelection();
if (sel.rangeCount && sel.getRangeAt) {
range = sel.getRangeAt(0);
alert(range);
}
document.designMode = "on";
if (range) {
sel.removeAllRanges();
sel.addRange(range);
alert(range);
}
// document.execCommand("Bold", false, null);
document.execCommand("BackColor", "false", "yellow");
document.designMode = "ofx f";
}
}
</script>
but using this code i m getting problem in firefox but it works fine in IE,Chrome and also i have show highlight the text when same user open same page next time For that i have to store text in my database.
Reply
Answers (
2
)
Related to ADO.Net
What browsers does Silverlight run in and what browsers and versions of browsers does Silverlight not run in?