PDA

View Full Version : link pop-up for rich text editor



orhun
12-21-2009, 08:54 PM
iam trying to use the code at below

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:

orhun
12-22-2009, 02:04 PM
no one have any idea?

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

orhun
12-24-2009, 04:59 PM
??????

jscheuer1
12-24-2009, 06:06 PM
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:


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