trim9001
08-22-2006, 11:19 PM
Hello guys! Here is a script that i have been wokin on. :thumbsup: The good part is that the script works in IE, however this script dosen't work in Firefox. I cant seem to find the problem. Can anyone please HELPPPP!!!:confused:
JAVASCRIPT
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Untitled Document</title>
<script language="javascript">
function format_sel(v) {
var str = document.selection.createRange().text;
document.my_form.my_textarea.focus();
var sel = document.selection.createRange();
sel.text = "<" + v + ">" + str + "</" + v + ">";
return;
}
function insert_link() {
var str = document.selection.createRange().text;
document.my_form.my_textarea.focus();
var my_link = prompt("Enter URL:","http://");
if (my_link != null) {
var sel = document.selection.createRange();
sel.text = "<a href=\"" + my_link + "\">" + str + "</a>";
}
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>
<link href="styles.css" rel="stylesheet" type="text/css" />
</head>
<body>
<form name="my_form">
<div id="toolbar">
<img class="button"
onmouseover="mouseover(this);"
onmouseout="mouseout(this);"
onmousedown="mousedown(this);"
onmouseup="mouseup(this);"
onclick="format_sel('b');"
src="bold.gif"
width="16" height="16"
align="middle"
alt="click to make your selection bold" />
<img class="button"
onmouseover="mouseover(this);"
onmouseout="mouseout(this);"
onmousedown="mousedown(this);"
onmouseup="mouseup(this);"
onclick="format_sel('i');"
src="italic.gif"
width="16" height="16"
align="middle"
alt="click to make your selection italic" />
<img class="button"
onmouseover="mouseover(this);"
onmouseout="mouseout(this);"
onmousedown="mousedown(this);"
onmouseup="mouseup(this);"
onclick="insert_link();"
src="link.gif"
width="32" height="16"
align="middle"
alt="click to add a link" /></div>
<textarea cols="30" rows="6" name="my_textarea"></textarea>
</form>
</body>
</html>
:thumbsup:
JAVASCRIPT
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Untitled Document</title>
<script language="javascript">
function format_sel(v) {
var str = document.selection.createRange().text;
document.my_form.my_textarea.focus();
var sel = document.selection.createRange();
sel.text = "<" + v + ">" + str + "</" + v + ">";
return;
}
function insert_link() {
var str = document.selection.createRange().text;
document.my_form.my_textarea.focus();
var my_link = prompt("Enter URL:","http://");
if (my_link != null) {
var sel = document.selection.createRange();
sel.text = "<a href=\"" + my_link + "\">" + str + "</a>";
}
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>
<link href="styles.css" rel="stylesheet" type="text/css" />
</head>
<body>
<form name="my_form">
<div id="toolbar">
<img class="button"
onmouseover="mouseover(this);"
onmouseout="mouseout(this);"
onmousedown="mousedown(this);"
onmouseup="mouseup(this);"
onclick="format_sel('b');"
src="bold.gif"
width="16" height="16"
align="middle"
alt="click to make your selection bold" />
<img class="button"
onmouseover="mouseover(this);"
onmouseout="mouseout(this);"
onmousedown="mousedown(this);"
onmouseup="mouseup(this);"
onclick="format_sel('i');"
src="italic.gif"
width="16" height="16"
align="middle"
alt="click to make your selection italic" />
<img class="button"
onmouseover="mouseover(this);"
onmouseout="mouseout(this);"
onmousedown="mousedown(this);"
onmouseup="mouseup(this);"
onclick="insert_link();"
src="link.gif"
width="32" height="16"
align="middle"
alt="click to add a link" /></div>
<textarea cols="30" rows="6" name="my_textarea"></textarea>
</form>
</body>
</html>
:thumbsup: