/    Sign up×
Community /Pin to ProfileBookmark

Javascript problem

Hi,

I am having a problem with the below code, with Firefox, I get the following error, when clicking on a smile

Can anyone help me ?

Firefox Error: obj_ta has no properties line 102

Line 102 is (Full Code below):

[code]else if ( obj_ta.selectionEnd )[/code]

Full Code below

[code]//Smile Start

var myAgent = navigator.userAgent.toLowerCase();
var myVersion = parseInt(navigator.appVersion);

var is_ie = ((myAgent.indexOf(“msie”) != -1) && (myAgent.indexOf(“opera”) == -1));
var is_nav = ((myAgent.indexOf(‘mozilla’)!=-1) && (myAgent.indexOf(‘spoofer’)==-1)
&& (myAgent.indexOf(‘compatible’) == -1) && (myAgent.indexOf(‘opera’)==-1)
&& (myAgent.indexOf(‘webtv’) ==-1) && (myAgent.indexOf(‘hotjava’)==-1));

var is_win = ((myAgent.indexOf(“win”)!=-1) || (myAgent.indexOf(“16bit”)!=-1));
var is_mac = (myAgent.indexOf(“mac”)!=-1);

function smile( txt ) {
// document.all.txtmessage.value = document.all.txtmessage.value + txt;
// return false;
doInsert(” ” + txt + ” “, “”, false,document.getElementById(‘txtmessage’));
}
function smile2( txt ) {
doInsert(” ” + txt + ” “, “”, false,document.getElementById(‘txttemplate’));
}
function doInsert(ibTag, ibClsTag, isSingle, name_txt)
{
var isClose = false;
var obj_ta = name_txt;

//—————————————-
// It’s IE!
//—————————————-
if ( (myVersion >= 4) && is_ie && is_win)
// if ( (ua_vers >= 4) && is_ie && is_win)
{
if (obj_ta.isTextEdit)
{
obj_ta.focus();
var sel = document.selection;
var rng = sel.createRange();
rng.colapse;
if((sel.type == “Text” || sel.type == “None”) && rng != null)
{
if(ibClsTag != “” && rng.text.length > 0)
ibTag += rng.text + ibClsTag;
else if(isSingle)
isClose = true;

rng.text = ibTag;
}
}
else
{
//– mod_bbcode begin
// this should work with Mozillas
if ( (myVersion >= 4) && is_win) {
var length = obj_ta.textLength;
var start = obj_ta.selectionStart;
var end = obj_ta.selectionEnd;
if (end == 1 || end == 2)
end = length;
var head = obj_ta.value.substring(0,start);
var rng = obj_ta.value.substring(start, end);
var tail = obj_ta.value.substring(end, length);
if( start != end ){
if (ibClsTag != “” && length > 0)
ibTag += rng + ibClsTag;
else if (isSingle)
isClose = true;
rng = ibTag;
obj_ta.value = head + rng + tail;
start = start + rng.length;
}
else{
if(isSingle)
isClose = true;
obj_ta.value = head + ibTag + tail;
start = start + ibTag.length;
}
obj_ta.selectionStart = start;
obj_ta.selectionEnd = start;
}
else {
//– mod_bbcode end
if(isSingle)
{
isClose = true;
}

obj_ta.value += ibTag;
//– mod_bbcode begin
}
//– mod_bbcode end
}
}
//—————————————-
// It’s MOZZY!
//—————————————-

else if ( obj_ta.selectionEnd )
{
var ss = obj_ta.selectionStart;
var st = obj_ta.scrollTop;
var es = obj_ta.selectionEnd;

if (es <= 2)
{
es = obj_ta.textLength;
}

var start = (obj_ta.value).substring(0, ss);
var middle = (obj_ta.value).substring(ss, es);
var end = (obj_ta.value).substring(es, obj_ta.textLength);

//———————————–
// text range?
//———————————–

if (obj_ta.selectionEnd – obj_ta.selectionStart > 0)
{
middle = ibTag + middle + ibClsTag;
}
else
{
middle = ibTag + middle;

if (isSingle)
{
isClose = true;
}
}

obj_ta.value = start + middle + end;

var cpos = ss + (middle.length);

obj_ta.selectionStart = cpos;
obj_ta.selectionEnd = cpos;
obj_ta.scrollTop = st;

}
//—————————————-
// It’s CRA**Y!
//—————————————-
else
{
if (isSingle)
{
isClose = true;
}

obj_ta.value += ibTag;
}

obj_ta.focus();

return isClose;
}

function CDE(elemId) {
if(document.getElementById(elemId).style.display != “none”)
document.getElementById(elemId).style.display = “none”
else
document.getElementById(elemId).style.display = “inline”
}

//Smile End[/code]

Regards,
Garry

to post a comment
JavaScript

0Be the first to comment 😎

×

Success!

Help @zc1 spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 5.17,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,

tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,
)...