Chocolate570 Posted December 24, 2005 Share Posted December 24, 2005 So, i'm helping a person with their forum. Everything's great except for one thing: The bbcode inserting function doesn't work in firefox. I think I have discovered the problem, it's the document.selection. From what I remember a long time ago, that's an IE only method. Correct? So I need to figure out how to make the function work cross-browser. I have also learnt that document.getSelection() works cross-browser, but how to integrate it? And do you see any other problems with this code? Thank you very much.This is the function that inserts the bbcode into the post box with the attribute name set as "post". function createlist(){ f1.post.focus(); var selected = document.selection; var srange = selected.createRange(); srange.colapse; if(srange.text=="") alert('There is no text selected to format'); else { nq=srange.text.split("\n").join("\n[*]"); srange.text="[*]" + nq; }} function LBC(func){ f1.post.focus(); var seected = document.getSelection; var srange = selected.createRange; srange.colapse; var nq=srange.text; if(srange.text=="") alert('There is no text selected to format'); else { switch(func) {case 'b':nq="[b]"+srange.text+"[/b]"; break;case "i":nq="[i]"+srange.text+"[/i]"; break;case "u":nq="[u]"+srange.text+"[/u]"; break;case "img": nq="[img="+srange.text+"]; break;case "q":nq="[QUOTE]"+srange.text+"[/QUOTE]"; break;case "c":nq="[CODE]"+srange.text+"[/code ]"; break;case "url":nq="[url=http://"+srange.text+"]"+srange.text+"[/url]"; break; } srange.text=nq;}}f1.name.focus(); Thank you very much in advance.<Chocolate570> Link to comment Share on other sites More sharing options...
Patriot Posted December 25, 2005 Share Posted December 25, 2005 i don't know much about javascript, but if im not mistaken isn't it all case sensitive?instead of case "c":nq="[CODE]"+srange.text+"[/code ]"; break;[/code]shouldn't it be[code]case "c":nq="[code]"+srange.text+"[/code ]"; break;[/code]not sure if that will help, or if it matters. Link to comment Share on other sites More sharing options...
Chocolate570 Posted December 25, 2005 Author Share Posted December 25, 2005 The is just added into the text box, it's not actually a variable or a function. Ty for replying, though. Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now