473,498 Members | 1,656 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

How to get BB code script to work in mozilla?

32 New Member
Hi all,
I have small bbcode script that works perfectly in IE. but in mozilla it doesn't work
here is script
Expand|Select|Wrap|Line Numbers
  1. <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" 
  2.     "http://www.w3.org/TR/html4/strict.dtd" 
  3.     > 
  4. <html> 
  5. <head> 
  6.     <head> 
  7. <!-- ... --> 
  8. <script language="JavaScript" type="text/javascript"> 
  9. var v=2; 
  10. <!-- 
  11. function createTag(tagId,areaId) { 
  12. //   var x=tagId; 
  13.  
  14.  
  15.    var txtArea = document.getElementById(areaId); 
  16.     var aSelection = document.selection.createRange().text; 
  17.     var range = txtArea.createTextRange(); 
  18.  
  19.  
  20.         if(aSelection) { 
  21.             // Add tags around selection 
  22.             document.selection.createRange().text = '['+tagId+']' + aSelection + '[/'+tagId+']'; 
  23.             txtArea.focus(); 
  24.             range.move('textedit'); 
  25.             //range.select(); 
  26.         } 
  27.  
  28.         else { 
  29.             //var oldStringLength = range.text.length + '['+tagId+']'.length; 
  30.                         if(v==2){ 
  31.             txtArea.value += '['+tagId+']'; 
  32.             //txtArea.value += '[/'+tagId+']'; 
  33.                         v=1; 
  34.                         } 
  35.                         else { 
  36.                             txtArea.value += '[/'+tagId+']'; 
  37.                             v=2; 
  38.                         } 
  39.             txtArea.focus(); 
  40.             range.move('character',oldStringLength); 
  41.             range.collapse(false); 
  42.             //range.select(); 
  43.         } 
  44.     if ((txtArea.selectionStart) || (txtArea.selectionStart == '0')) { 
  45.  
  46.             var startPos = txtArea.selectionStart; 
  47.  
  48.         var endPos = txtArea.selectionEnd; 
  49.  
  50.         txtArea.value = txtArea.value.substring(0, startPos)+'az'+ txtArea.value.substring(endPos, txtArea.value.length); 
  51.  
  52.  
  53.  
  54.             return txtArea.value 
  55.  
  56.  
  57.         } 
  58.  
  59. //--> 
  60. </script> 
  61. </head> 
  62. <body> 
  63. <!-- ... --> 
  64.     <form onSubmit="return true;"> 
  65.         <textarea id="txtA" rows=20 cols=40></textarea> 
  66.     </form> 
  67.     <a href="javascript<b></b>:createTag('b','txtA')"><strong>B</strong></a> 
  68.         <a href="javascript<b></b>:createTag('i','txtA')"><strong>i</strong></a> 
  69. <!-- ... --> 
  70. </body> 
  71. </body> 
  72. </html> 
  73.  
Can anyone help me so that it works both in IE and Mozilla Firefox
Thanks for advance
Jan 29 '11 #1
2 1548
Dormilich
8,658 Recognized Expert Moderator Expert
the Range object in IE and the Range object in Mozilla are fundamentally different (ref.) you need to use/develop a cross-browser version for your code.
Jan 30 '11 #2
Ketrid
4 New Member
Get rid of the bold tags in the middle of your javascript call, look before the function:
<a href="javascript<b></b>:createTag('b','txtA')"><strong>B</strong></a>

To simplify the inter-browser compatibility, use jquery and let the API do the work of figuring out those different commands for you.
Feb 13 '11 #3

Sign in to post your reply or Sign up for a free account.

Similar topics

1
2038
by: Grytpype-Thynne | last post by:
I have a test page at http://www.animals-in-distress.net/home2.htm it has a left menu and the rest of the page for content, I also have the content appear in the html before the menu. The page...
6
5155
by: Patrick | last post by:
Hi I am fairly new to CSS and the web.I am trying to build a site more to practice my skills than for the site itself. I have been focusing on CSS and try my best to make it work in I.E 6.0,...
2
3964
by: swathi | last post by:
----------------------------------------------------------------------- A poll associated with this post was created, to vote and see th results, please visit...
6
1504
by: GD | last post by:
I'm using a script that works great on IE, but not on mozilla. the original one worked also on N4, but i'd like it to be funcional with mozilla. this is the orginal script: ...
9
5549
by: fochie | last post by:
Greetings, I'm having a problem when I try to GET a file from my server via xmlhttp when using Mozilla. With IE I can get any type of file fine, get/display headers fine, etc. With Mozilla,...
4
4414
by: conckrish | last post by:
Hai All, In my ASP.NET application, I have created a popup window using a mouseover event for Label.I have placed all popup controls inside a div tag.This popup working well in IE,but not...
1
1435
by: hamidawais | last post by:
Hi All I have a simple Ajax example that populates a combo box from the DB . The example is working fine on Internet explorer but it gives no result on Mozilla FireFox Given below is the...
5
1635
by: gsreenathreddy | last post by:
hi! I am sending the code which is worked on browsers IE and Eclipse internal browser but not with mozilla. which is used to generate dynamic time on key stroke. <html> <body> <script...
1
2865
by: haribabu1982 | last post by:
HI , I am getting problem with mozilla if i use these type of html and css.please help me. image is wrapping around and some times image is missing. Here is the code
3
2528
by: rahulgupta | last post by:
i have a textbox and a save_btn which is a hyperlink. when ever enter key is pressed there is a javascript which check if the name in the textbox contains any special characters. but when we press...
0
7125
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
7002
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
7165
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
1
4910
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
4590
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
3093
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
3085
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
656
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
291
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.