christianbecker
Programmer
Hello,
this is my first time to make a thread. I read the following thread (thread216-169712) that addressed an inquiry for a script that adds HTML bold formating to an asp form. davidbyng replied:
Check vituz post :
Thread216-144664
I tested the code from that thread on Mac with IE 5 and recieved the following error:
Microsoft JScript runtime error
"null" is not an object
this referred to the following line of code
sel=(IE)?doument.selection;(NC)?document.getSelection():null
The following scripts work fine on PC but not on mac. The first one is the one from Thread216-144664. The second one is from a gentleman is Germany.
<!--
var IE=document.all || document.getElementById
var NC=document.layers
function Inserty(){
var prestart,preend,start,end,sel,range,thetext,dvsn,colname,theform,formname,colselname,colsel,effselname,effsel,effname,eff
formname="myne"
colselname="colorName"
effselname="effectName"
theform=document.forms[formname]
colsel=theform[colselname]
effsel=theform[effselname]
colname=colsel.options[colsel.selectedIndex].value
effname=effsel.options[effsel.selectedIndex].text
eff=effsel.options[effsel.selectedIndex].value
dvsn=["[","]","[/"]
prestart=""
preend=""
if (colname!='none'){
prestart=dvsn[0]+'color '+colname+dvsn[1]
preend=dvsn[2]+'color'+dvsn[1]
}
start=(effname!='color')?prestart+dvsn[0]+eff+dvsn[1]
restart
end=(effname!='color')?dvsn[2]+eff+dvsn[1]+preend
reend
sel=(IE)?document.selection
NC)?document.getSelection():null
range=sel.createRange()
thetext=range.text
if (thetext.length){
range.text=start+thetext+end
}}
//-->
</script>
<script language="JavaScript" type="text/javascript">
<!--
function FormatText(Tag) {
tmpStartTag = "<" + Tag + ">";
tmpEndTag = "</" + Tag + ">";
GetSelection(tmpStartTag, tmpEndTag, null);
}
function GetSelection(strBefore, strAfter, strContent) {
var Selection = document.selection.createRange();
if (Selection.text != "" && Selection.text != null) {
Selection.text = strBefore + Selection.text + strAfter;
} else {
document.News.Text.value = document.News.Text.value + strBefore + strContent + strAfter;
}
}
//-->
I would appreciate any help to make these code work on MAC or any reference to other codes do do the same function that work on mac.
many thanks.
Christian Becker
cbecker@sarasotamagazine.com
this is my first time to make a thread. I read the following thread (thread216-169712) that addressed an inquiry for a script that adds HTML bold formating to an asp form. davidbyng replied:
Check vituz post :
Thread216-144664
I tested the code from that thread on Mac with IE 5 and recieved the following error:
Microsoft JScript runtime error
"null" is not an object
this referred to the following line of code
sel=(IE)?doument.selection;(NC)?document.getSelection():null
The following scripts work fine on PC but not on mac. The first one is the one from Thread216-144664. The second one is from a gentleman is Germany.
<!--
var IE=document.all || document.getElementById
var NC=document.layers
function Inserty(){
var prestart,preend,start,end,sel,range,thetext,dvsn,colname,theform,formname,colselname,colsel,effselname,effsel,effname,eff
formname="myne"
colselname="colorName"
effselname="effectName"
theform=document.forms[formname]
colsel=theform[colselname]
effsel=theform[effselname]
colname=colsel.options[colsel.selectedIndex].value
effname=effsel.options[effsel.selectedIndex].text
eff=effsel.options[effsel.selectedIndex].value
dvsn=["[","]","[/"]
prestart=""
preend=""
if (colname!='none'){
prestart=dvsn[0]+'color '+colname+dvsn[1]
preend=dvsn[2]+'color'+dvsn[1]
}
start=(effname!='color')?prestart+dvsn[0]+eff+dvsn[1]
end=(effname!='color')?dvsn[2]+eff+dvsn[1]+preend
sel=(IE)?document.selection
range=sel.createRange()
thetext=range.text
if (thetext.length){
range.text=start+thetext+end
}}
//-->
</script>
<script language="JavaScript" type="text/javascript">
<!--
function FormatText(Tag) {
tmpStartTag = "<" + Tag + ">";
tmpEndTag = "</" + Tag + ">";
GetSelection(tmpStartTag, tmpEndTag, null);
}
function GetSelection(strBefore, strAfter, strContent) {
var Selection = document.selection.createRange();
if (Selection.text != "" && Selection.text != null) {
Selection.text = strBefore + Selection.text + strAfter;
} else {
document.News.Text.value = document.News.Text.value + strBefore + strContent + strAfter;
}
}
//-->
I would appreciate any help to make these code work on MAC or any reference to other codes do do the same function that work on mac.
many thanks.
Christian Becker
cbecker@sarasotamagazine.com