Been racking my brains for hours over this, if I fix it for Firefox the problem then appears in IE and visa-versa.
I run a forum called E-Blah and have a test site at:
http://www.warlock.4you.za.org/blah95/Blah.pl?The forum is perl based with some javascript functions
When posting a thread if you highlight some given text and then hit a code tag button, lets say B
It should replace the highlighted text with [b]the text[/b]. This works perfectly in IE and Opera but in Firefox I get thetext[b][/b], it ignores the selected text and places the code tags at the end.
Here is the code from bc.js
function use(u,c) {
var bb_obj = document.msend.message;
if(document.all && window.navigator.userAgent
.toLowerCa
se().index
Of('opera'
)) {
bb_obj.focus();
selecttext = document.selection.createR
ange().tex
t;
if((selecttext && c) || bb_obj.isTextEdit) {
if(bb_obj.isTextEdit && !selecttext) {
var sel = document.selection;
var nrn = sel.createRange();
nrn.colapse;
nrn.text = u;
if(c) { nrn.text = c; }
} else {
document.selection.createR
ange().tex
t = u+selecttext+c;
}
} else {
bb_obj.value += u;
if(c) { bb_obj.value += c; }
}
} else {
if(!c) { c = ''; }
bb_obj.value += u+c;
}
bb_obj.focus();
selecttext = '';
}
function openuse(u) {
var bbo_obj = opener.document.msend.mess
age;
bbo_obj.value += u;
}
function AddNewValue(bc,thenewvalue
) {
if(bc != '' && thenewvalue != '') {
use("["+bc+"="+thenewvalue
+"]","[/"+
bc+"]");
document.msend.color.value
= '';
document.msend.face.value = '';
document.msend.size.value = '';
document.msend.glow.value = '';
document.msend.shadow.valu
e = '';
}
}
function funclu (lookup) {
document.getElementById('a
bout').inn
erHTML = eval('func_'+lookup);
}
and the code from Post.pl
The bc.js file is called at the begining of a sub
<script language="JavaScript" src="$bcloc" type="text/javascript"></s
cript>
The rest of the code follows this format:
<td><img src="$images/bold.gif" border="0" alt="$var{'10'}" $ghand onClick="use('[b]','[/b]')
;" onMouseOver="funclu('b');"
>
<img src="$images/italics.gif" border="0" alt="$var{'11'}" $ghand onClick="use('[i]','[/i]')
;" onMouseOver="funclu('i');"
>
etc etc
See this post also:
http://www.experts-exchange.com/Web/Web_Languages/JavaScript/Q_21671865.htmlCan anyone help to solve this as a lot of my members are switching to Firefox.
If you need anymore info then please ask. if you need to look at this in action on the test site the username = tester password = tester
Many thank's in advance.
Martin