0

Hi all,
I have small bbcode script that works perfectly in IE. but in mozilla it doesn't work
here is script

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"
    "http://www.w3.org/TR/html4/strict.dtd"
    >
<html>
<head>
    <head>
<!-- ... -->
<script language="JavaScript" type="text/javascript">
var v=2;
<!--
function createTag(tagId,areaId) {
 //   var x=tagId;
	
   
   var txtArea = document.getElementById(areaId);
	var aSelection = document.selection.createRange().text;
	var range = txtArea.createTextRange();


		if(aSelection) {
			// Add tags around selection
			document.selection.createRange().text = '['+tagId+']' + aSelection + '[/'+tagId+']';
			txtArea.focus();
			range.move('textedit');
			//range.select();
		}
                
		else {
			//var oldStringLength = range.text.length + '['+tagId+']'.length;
                        if(v==2){
			txtArea.value += '['+tagId+']';
			//txtArea.value += '[/'+tagId+']';
                        v=1;
                        }
                        else {
                            txtArea.value += '[/'+tagId+']';
                            v=2;
                        }
			txtArea.focus();
			range.move('character',oldStringLength);
			range.collapse(false);
			//range.select();
		}
	if ((txtArea.selectionStart) || (txtArea.selectionStart == '0')) {
            
            var startPos = txtArea.selectionStart;

        var endPos = txtArea.selectionEnd;

        txtArea.value = txtArea.value.substring(0, startPos)+'az'+ txtArea.value.substring(endPos, txtArea.value.length);


            
            return txtArea.value
            
            
        }
       
}
//-->
</script>
</head>
<body>
<!-- ... -->
	<form onSubmit="return true;">
		<textarea id="txtA" rows=20 cols=40></textarea>
	</form>
	<a href="javascript:createTag('b','txtA')"><strong>B</strong></a>
        <a href="javascript:createTag('i','txtA')"><strong>i</strong></a>
<!-- ... -->
</body>
</body>
</html>

Can anyone help me so that it works both in IE and Mozilla Firefox
Thanks for advance

2
Contributors
1
Reply
2
Views
6 Years
Discussion Span
Last Post by Troy III
0

check if FF suports the textRange method first,
if not,
see if FF provides an alternative method/syntax
than substitute your existing code where necessary.

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.