Skip to main content
gamedev.net
🔒 Locked

[web] Javascript, Firefox To IE

Started by dave 0 replies 350+ views
Original Post
dave
dave
I have this &#106avascript function which i have written to take a highlight piece of text in the control passed in and wrap it in bold tags, this works in Firefox, but not in IE.

function MakeBold( txtarea )
{	
	var before 	= (txtarea.value).substring(0,txtarea.selectionStart);
        var selection	= (txtarea.value).substring(txtarea.selectionStart, txtarea.selectionEnd);
	var after	= (txtarea.value).substring(txtarea.selectionEnd,txtarea.value.length);

        txtarea.value = before+""+selection+""+after;
}


Does anyone have any idea how i get this to work in IE? Currently all that happens is that it appears to double up the string: In IE: original is: 123 and after running that function i get: 123123123 rather than 123 Any ideas? Dave

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.