01-25-2008, 09:41 PM
|
#7 (permalink)
|
|
The Addict
Join Date: Nov 2007
Posts: 282
Thanks: 61
|
Your correct, I got this code so far:
Code:
<html>
<head>
<title>Debug mode</title>
<script type='text/javascript'>
function insertTag(tag)
{
if(document.selection)
{
}
else
{
var v = window.document.f.post;
var start = v.value.substr(0,v.selectionStart);
var end = v.value.substr(v.selectionEnd,v.value.length);
var middle = v.value.substr(v.selectionStart,v.selectionEnd);
content = start + "["+tag+"]" + middle + "[/"+tag+"]" + end
//v.value = content
alert(start+" ------ "+middle+" ------ "+end);
}
}
</script>
</head>
<body>
<input onclick='insertTag("b")' type='button' value='b' />
<input onclick='insertTag("i")' type='button' value='i' />
<input onclick='insertTag("u")' type='button' value='u' />
<input onclick='insertTag("s")' type='button' value='s' />
<input onclick='insertTag("sub")' type='button' value='sub' />
<form name='f' action='' method='post'>
<textarea cols=100 rows=10 name='post'></textarea>
</form>
</body>
</html>
Example code: Debug mode
In IE 7 I added the if statement because the start position and end position would grab all text :(, so I added the if statement can someone help me learn how to get it working with IE 7. createRange is confusing.
__________________
PHP/XHTML Freelancer:
Cleanscript.com v3 - Programming starting at just $5 act now!
|
|
|
|