| | |||||
| ||||||||
| Programming PHP, Perl, Ruby on Rails, AJAX, HTML, XHTML, CSS, JavaScript, MySQL and any other coding topics. |
![]() |
| | LinkBack | Thread Tools |
| | THREAD STARTER #1 (permalink) |
| The original NP Emo Kid Join Date: Jan 2005 Location: Plymouth, UK
Posts: 1,693
![]() ![]() ![]() ![]() ![]() ![]() | [javascript] Error in google chrome Basically my bbcode insertion javascript works near on perfect in all browsers now apart from chrome. It seems to repeat whatever is before it when you enter text: 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(typeof(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(typeof(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();
} ????: NamePros.com http://www.namepros.com/programming/595360-javascript-error-in-google-chrome.html Prxa.info Message Board >> Add New Topic In chrome it will delete whatever was before it when entering the bbcode into the box and repeat stuff, test above to see what i mean |
| | |
| | #2 (permalink) |
| Programming Genius Join Date: Aug 2003 Location: Las Vegas
Posts: 949
![]() ![]() ![]() ![]() ![]() ![]() | I am not really sure what the fix would be. I use jQuery which will work across all browsers. Doing it from scratch can be a pain since all of the browsers render javascript differently.
__________________ Web Design / Programming / Graphic Design | Bonk-Media | My Domaining Blog Latest Projects Include: Mariel Mendoza | Local Tanning Salon | Grease Monkey |
| | |
| | #4 (permalink) |
| NamePros Member Join Date: Sep 2006
Posts: 99
![]() ![]() | Chrome has an awesome debugging console. The line throwing out problems is: Code: var longueur = parseInt(obj.textLength); Just use: Code: var longueur = parseInt(obj.value.length); ????: NamePros.com http://www.namepros.com/showthread.php?t=595360 Bruce |
| | |
![]() |
| Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
| Thread Tools | |
| |
Similar Threads | ||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Huge Geo Sale! Country, Cities and more! New-England, FrenchGuiana, Nordanstig.com... | thevirtual | Domains For Sale - Make Offer | 15 | 01-31-2008 11:09 AM |
| ~ LowCostMeal.com only $7 ~ (Google indexed!!) | JasMate | Domains For Sale - Fixed Price | 0 | 09-06-2006 11:39 PM |
| google ranking (Tips) | lilgee | Search Engines | 8 | 10-20-2005 03:04 PM |
| Premium Domain Clearance Tax Sale $10+ | clemzonguy | Domains For Sale - Fixed Price | 2 | 04-11-2005 04:30 PM |