Dynadot Aftermarket: discover domain gems worth investing in. Visit our aftermarket.

[Javascript] errors in IE 8

Namecheap AuctionsNamecheap Auctions
Spacemail by SpaceshipSpacemail by Spaceship
SpaceshipSpaceship
Watch

liam_d

The original NP Emo KidEstablished Member
Impact
25
I currently us the below code for javascript insertion which works fine in FF & Opera but gives errors in IE.

(this was from a tutorial i found)
Code:
// add simple text
function addText(Text)
{
	var obj = document.form.message;
	obj.focus();
 
	if (document.selection && document.selection.createRange)  // Internet Explorer
	{
		sel = document.selection.createRange();
		if (sel.parentElement() == obj)  
		{
			sel.text = Text;
		}
	}

	else if (obj != "undefined")  // Firefox
	{
		var longueur = parseInt(obj.textLength);
		var selStart = obj.selectionStart;
		var selEnd = obj.selectionEnd;

		obj.value = obj.value.substring(0,selStart) + Text + obj.value.substring(selEnd,longueur);
	}
 
	else 
	{
		obj.value += Text;
	}

	obj.focus();
}

// wrap code in tags or just simply add them by themselves
function addTags(Tag, fTag)
{
	var obj = document.form.message;
	obj.focus();

	// Internet Explorer
	if (document.selection && document.selection.createRange) 
	{
		sel = document.selection.createRange();
		if (sel.parentElement() == obj)
		{
			sel.text = Tag + sel.text + fTag;
		}
	}

	// Firefox
	else if (obj != "undefined")
	{
		var longueur = parseInt(obj.textLength);
		var selStart = obj.selectionStart;
		var selEnd = obj.selectionEnd;

		obj.value = obj.value.substring(0,selStart) + Tag + obj.value.substring(selStart,selEnd) + fTag + obj.value.substring(selEnd,longueur);
	}
 
	else
	{	
		obj.value += Tag + fTag;
	}

	obj.focus();
}

Here is a screenshot of the error:
http://i43.photobucket.com/albums/e397/clericvash/jserror.jpg

I am no good at all with JS so i don't know what it means?
 
0
Close
The views expressed on this page by users and staff are their own, not those of NamePros.
GoDaddyGoDaddy
DomainEasy: flexible LTO options. Close more domain deals with financing.

We're social

Escrow.com
Spaceship
Domain Recover
CryptoExchange.com

NamePros updates

Switch between accounts
You can now stay logged in to more than one NamePros account in the same browser. Click your avatar, then "Accounts in this browser", to...
AIVikings
Catchy
  • The sidebar remains visible by scrolling at a speed relative to the page’s height.
Back