Results 1 to 4 of 4

Thread: link pop-up for rich text editor

  1. #1
    Join Date
    Aug 2009
    Posts
    18
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default link pop-up for rich text editor

    iam trying to use the code at below
    Code:
    function link(word) { 
    var name = prompt("Link:", "http://"); 
    var aTag =  '[' + tag + '=/'; var btag = '/]';
    var createlink = aTag + name + btag;
    } 
    
    <a href="#" onclick="link('a');"><img alt="Link" src="createlink.gif" border="0"></a>
    for adding link to my rich-text editor.

    i can create pop-up box for the "link section"... but.... could some help me to add the writtens on pop-up, to the text-area?(adding "createlink" to text-area)

    the writtens for link, must be added to the text area like this:

    [link: /www.site.com/][/link]
    Last edited by orhun; 12-21-2009 at 09:00 PM.

  2. #2
    Join Date
    Aug 2009
    Posts
    18
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    no one have any idea?

    "if my question isnt clear".. please tell...

  3. #3
    Join Date
    Aug 2009
    Posts
    18
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    ??????

  4. #4
    Join Date
    Mar 2005
    Location
    SE PA USA
    Posts
    30,495
    Thanks
    82
    Thanked 3,449 Times in 3,410 Posts
    Blog Entries
    12

    Default

    It already has a link button. The way the editor works though is via the execCommand() method, which can only insert valid HTML tags, not bb code tags like you say you want. But, what really matters I would think is the value that the form submits. For that, the value of the hidden field (configured via the fieldname argument of the writeRichText function) could be altered using regular expressions, or some other string altering method. For example:

    Code:
    <form name="RTEDemo" action="demo.htm" method="post" onsubmit="return submitForm();">
    <script language="JavaScript" type="text/javascript">
    <!--
    function submitForm() {
    	//make sure hidden and iframe values are in sync before submitting form
    	//to sync only 1 rte, use updateRTE(rte)
    	//to sync all rtes, use updateRTEs
    	updateRTE('rte1');
    	//updateRTEs();
    document.RTEDemo.rte1.value = document.RTEDemo.rte1.value.replace(/</g, '[').replace(/>/g, ']');
    	alert("rte1 = " + document.RTEDemo.rte1.value);
    	
    	//change the following line to true to submit form
    	return false;
    }
    
    //Usage: initRTE(imagesPath, includesPath, cssFile)
    initRTE("images/", "", "");
    //-->
    </script>
    <noscript><p><b>Javascript must be enabled to use this form.</b></p></noscript>
    
    <script language="JavaScript" type="text/javascript">
    <!--
    //Usage: writeRichText(fieldname, html, width, height, buttons, readOnly)
    writeRichText('rte1', 'here's the "<em>preloaded</em> <b>content</b>"', 400, 200, true, false);
    //-->
    </script>
    <p>Click submit to show the value of the text box.</p>
    <p><input type="submit" name="submit" value="Submit"></p>
    </form>
    If you check the View Source checkbox, you will see HTML code. But if you submit, you will see the value transformed to bb code. If this form were to actually submit (in this example it only alerts, returning false on the submission) it would submit the bb code version.
    - John
    ________________________

    Show Additional Thanks: International Rescue Committee - Donate or: The Ocean Conservancy - Donate or: PayPal - Donate

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •