liam1412 Posted July 12, 2007 Share Posted July 12, 2007 Hi This script was given to me by someone on here for use on my site. I know nothing of JS at all but he offered this for use (but can't remember who it was) [code]<script type="text/javascript"> function AddEmo(tag) { var emo=document.forms["form"].elements["text"]; if (document.selection) { emo.focus(); var sel = document.selection.createRange(); sel.text = tag } else if (emo.selectionStart || emo.selectionStart == '0') { var startPos = emo.selectionStart var endPos = emo.selectionEnd emo.value = emo.value.substring(0, startPos) + tag + emo.value.substring(endPos, emo.value.length) } else { emo.value += tag; } } function AddTag(tag) { var txt = ''; if (window.getSelection) { txt = window.getSelection(); } else if (document.getSelection) { txt = document.getSelection(); } else if (document.selection) { txt = document.selection.createRange().text; } var stri1 = txt var stri = "["+tag+"]"+stri1+"[/"+tag+"]" AddEmo(stri); } // calling the function </script> This script basically wraps BBCODE tags around highligted text. The I use my BBCODE php function to parse the text At the moment I use this for links so (url)http://www.phpfreaks.com(/url) but with sq brackets but bbcode on here is parsing it becomes CLick Here How would I ammend this script so that the text that is displayed is the actual URL itself. For info this is my parser code. function BBCODE($bbcode) { //the bbcode tags.. $bbc_a=array( "[strike]", "[/strike]", "[b]", "[/b]", "[u]", "[/u]", "[big]", "[/big]", "[huge]", "[/huge]", "[e_mail]", "[/e_mail]", "[url=http://", "]", "[/url]", "[url=http://", "]", "[/url]", "::smile::", "::mad::", "::sad::", "::", "::smirk::", "::wink::", "::surprised::", "::thinking::", "::tongue::", "::cool::", "[img]http://", "[/img]", "[img]http://", "[/img]", "[quote]", "[/quote]", "[quote]", "[/quote]", ); //bbcode gets converted to.. $bbc_b=array( "<strike>", "</strike>", "<b>", "</b>", "<u>", "</u>", "<font size=4>", "</font>", "<font size=8>", "</font>", "<a href=\"mailto:", "\">Click Here</a>", "<a href=\"", "\" target=\"blank\">click here</a>", "<a href=\"", "\" target=\"blank\">click here</a>", "<img src='images/smilies/smile.gif' border='0' />", "<img src='images/smilies/mad.gif' border='0' />", "<img src='images/smilies/sad.gif' border='0' />", "<img src='images/smilies/rolleyes.gif' border='0' />", "<img src='images/smilies/smirk.gif' border='0' />", "<img src='images/smilies/wink.gif' border='0' />", "<img src='images/smilies/surprised.gif' border='0' />", "<img src='images/smilies/thinking.gif' border='0' />", "<img src='images/smilies/tongue.gif' border='0' />", "<img src='images/smilies/cool.gif' border='0' />", "<img src='", "' border='2' />", "<img src='", "' border='2' />", "<div class='quote'>Quote:<br />", "</div>", "<div class='quote'>Quote:<br />", "</div>", ); $bbc_num=count($bbc_a); $loop=0; while($loop<$bbc_num) { $bbcode=str_replace($bbc_a[$loop], $bbc_b[$loop], $bbcode); $loop++; } return $bbcode; } [/code] Link to comment https://forums.phpfreaks.com/topic/59730-help-changing-this-little-script/ Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.