Jump to content

Some JavaScript which works in Opera 9 and not Firefox 3


Boylett

Recommended Posts

Hi

 

I have some JS which works in Opera, but doesn't work in FireFox

 

function AddBBCode(object,start,end)
{
    if(object.selectionStart != null)
    {
        object.value =
            object.value.substr(0,object.selectionStart)+
            start+
            object.value.substr(object.selectionStart,object.selectionEnd - object.selectionStart)+
            end+
            object.value.substr(object.selectionEnd);
    }
    else alert(
            "Your browser doesn't support JavaScript Range, so can't use these buttons correctly. Please upgrade to FireFox or Opera\r\n\r\n"+
            "The BBCode you selected was: "+start+end
        );
}

 

The code would get called from a button, i.e.:

onclick="javascript:AddBBCode(textarea,'[b]','[/b]');"

 

On IE it throws up the alert, but I'm not bother about that.

 

Please tell me how to get FireFox to work with it aswell ;D

 

Cheers,

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.