Hi everyone
This is part of a project I have been on for a little while and its quite close to working except for the bloody inevitable IE problem!!!
What this script does is wrap a selected bit of text within a text field with a tag eg:
my text
once highlighted and the bold button clicked would change the highlighted text to
<b>my text</b>
now my code works in all browsers except IE
So I have tried to use an alternative for IE but unfortunately the result is it’s just wrapping the text in a:
<undefined>my text</undefined>
tag
I am at the end of my tether on this so I am asking… can anyone see where my problem is
here is my example
<!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=UTF-8"/>
<title>select-test</title>
<style type="text/css">
<!--
body { margin:0px; background-color:#fff; height:100% }
html { height:100% }
form { margin:0px }
-->
</style>
<script type="text/javascript">
function formatText(el,tagstart,tagend,tag) {
if (el.setSelectionRange)
{
el.value = el.value.substring(0,el.selectionStart) + tagstart + el.value.substring(el.selectionStart,el.selectionEnd) + tagend + el.value.substring(el.selectionEnd,el.value.length)
}
else
{
//Bloody IE specific code !!!! whihc results in undefined//
var selectedText = document.selection.createRange().text;
if (selectedText != "")
{
var newText = "<" + tag + ">" + selectedText + "</" + tag + ">";
document.selection.createRange().text = newText;
}
}
}
</script>
</head>
<body>
<div id="PageDiv" style="position:relative; min-height:100%">
<form name="my_form">
<input type="button" value="BOLD" onclick="formatText(document.getElementById('myta'),'<b>','</b>')"/>
<textarea id="myta" rows="10" cols="30"></textarea>
<input type="submit" value="SUBMIT" />
</form>
</div>
</body>
</html>
this is only a test example to show the problem I am having… :o(
But the actual finished menu will be part of a new WebYep long-text menu … but as I said it still wont work in ie… yet… :o(
So if some one can see the blooming problem I will defiantly by them a mars bar… :o) or a chockie of there choice…
all the best max
actionsdev mailing list
email@hidden
Update your subscriptions at:
http://freewaytalk.net/person/options