Hey there
I'm an ASP coder and I'm building a web portal that involves a lot of user submissions. I made a text formatting toolbar in javascript which was basedon an oreillynet tutorial, but now I'm having problems. It appears that it works fine in IE, but refuses to work at all in Firefox. I've spoken to a few people on my usual ASP forum and they tell me that's because the code is "non standard" and firefox does not support non standard code. Anyway I'm here, basically to beg for help on making my code Javascript 'standard' Can anyone help?
My JavaScript functions are;
Code:
<script>
function format_sel(v) {
var str = document.selection.createRange().text;
document.form1.strMessage.focus();
var sel = document.selection.createRange();
sel.text = "[" + v + "]" + str + "[/" + v + "]";
return;
}
function format_sml(v) {
var str = document.selection.createRange().text;
document.form1.strMessage.focus();
var sel = document.selection.createRange();
sel.text = v;
return;
}
function insert_link() {
var str = document.selection.createRange().text;
document.form1.strMessage.focus();
var my_link = prompt("Enter URL:","http://");
if (my_link != null) {
var sel = document.selection.createRange();
sel.text = "[link]" + my_link + "[name]" + str + "[/name][/link]";
}
return;
}
function mouseover(el) {
el.className = "raised";
}
function mouseout(el) {
el.className = "button";
}
function mousedown(el) {
el.className = "pressed";
}
function mouseup(el) {
el.className = "raised";
}
</script>
And its called like this (example creates "bold" text)
Code:
<img class="button"
onMouseOver="mouseover(this);"
onMouseOut="mouseout(this);"
onMouseDown="mousedown(this);"
onMouseUp="mouseup(this);"
onClick="format_sel('b');"
src="../images/bold.gif"
align="middle"
alt="click to make your selection bold">
Any help would be very appreciated.