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,

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.