/    Sign up×
Community /Pin to ProfileBookmark

Will this work in IE?

On my site (bible-help.com) I want to allow users to comment. When they click the ‘bold’ button, I want <b> and </b> to appear around the selected text (similar to this forum). Here is the code I have that works for Chrome, Firefox, and Safari. I can’t tell if it works on IE cause I use a mac.

[CODE]function formatText(el, tag)
{
if (el.setSelectionRange)
{
el.value = el.value.substring(0,el.selectionStart) + “<” + tag + “>” + el.value.substring(el.selectionStart,el.selectionEnd) + “</” + tag + “>” + el.value.substring(el.selectionEnd,el.value.length)
}
}
[/CODE]

Does this work in IE?

If it doesn’t I saw this code somewhere:

[CODE]
function formatText(tag)
{
var selectedText = document.selection.createRange().text;
var newText = “<” + tag + “>” + selectedText + “</” + tag + “>”;
document.selection.createRange().text = newText;
}
[/CODE]

Will that work in IE?

Currently on my site I have the two combined, but I don’t know if it works:

If you can’t tell by reading this, feel free to create an account on the website to try it. It’s like a forum and after signing in, click on +Add New Question.

Thanks for your help!

to post a comment
JavaScript

1 Comments(s)

Copy linkTweet thisAlerts:
@DracoMerestAug 28.2011 — http://bible-help.com/view_question.php?question=103&title=Fake&#37;20Question%20#1

This page has Bold text in IE7. And italic and underlined too.
×

Success!

Help @condoravenue spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 5.16,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,

tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,
)...