delphi programming forums mysql charset mget recursive synonimos
free ventrilo servers hosting cs javascript delay python find in list
Back Forum New
abstract:

<input type="submit" name="btnBolrd" value="B" id="btnB" onClick="RTEDo('bold');" />
<input type="submit" name="btnItalic" id="btnI" value="I" onClick="RTEDo('italic');" />
<input type="submit" name="btnUnderline" id="btnU" value="U" onClick="RTEDo('underline');" />
<input type="submit" name="btnColor" id="btnC" value="red" onClick="RTEDo('color');" />
<input type="submit" name="btnLink" id="btnLink" value="Link" onClick="RTEDo('link');" />
<br />
<iframe id="rte">
</iframe>
</body>
</html>


I have a textarea that has a Bold, Italic and Underline buttons that change the appearance of what is in the textarea.
If I highlight a word in the textarea and hit the Bold, Italic and Underline buttons it changes the appearance of the word.
Everything works great and now I want to add a color button and Link button.  The color button should change the word color and the link button should make the word into a link.
Both buttons dont do anything.
Please advise what I am doing wrong and how to make them work?
Code:
  1. <style>
  2. #btnB{
  3. font-weight: bolder;
  4. }
  5. #btnI{
  6. font-style: italic;
  7. }
  8. #btnU{
  9. text-decoration: underline;
  10. }
  11. #btnC{
  12. font-color: red;
  13. }
  14. #btnLink{
  15. A:active;
  16. }
  17. </style>
  18. <html>
  19. <script type="text/javascript">
  20. var obj;
  21. function Init(){
  22. obj = document.getElementById("rte");
  23. obj.contentWindow.document.designMode = "On";
  24. }
  25. function RTEDo(name){
  26. obj.contentWindow.document.execCommand(name, false, null);
  27. }
  28. </script>
  29. <body onLoad="Init();">
  30. <input type="submit" name="btnBolrd" value="B" id="btnB" onClick="RTEDo('bold');" />
  31. <input type="submit" name="btnItalic" id="btnI" value="I" onClick="RTEDo('italic');" />
  32. <input type="submit" name="btnUnderline" id="btnU" value="U" onClick="RTEDo('underline');" />
  33. <input type="submit" name="btnColor" id="btnC" value="red" onClick="RTEDo('color');" />
  34. <input type="submit" name="btnLink" id="btnLink" value="Link" onClick="RTEDo('link');" />
  35. <br />
  36. <iframe id="rte">
  37. </iframe>
  38. </body>
  39. </html>
Copy Code

TOP

Don't you need to pass red and Link in as parameters to execCommand? I think the null is setting them the colour to black and the link to nothing. I don't think filling out the value will do it.
Yeah.. quick google reveals you need to execCommand('color', false, 'red')...
whiteatom



<input type="submit" name="btnBolrd" value="B" id="btnB" onClick="RTEDo('bold');" />
<input type="submit" name="btnItalic" id="btnI" value="I" onClick="RTEDo('italic');" />
<input type="submit" name="btnUnderline" id="btnU" value="U" onClick="RTEDo('underline');" />
<input type="submit" name="btnColor" id="btnC" value="red" onClick="RTEDo('color');" />
<input type="submit" name="btnLink" id="btnLink" value="Link" onClick="RTEDo('link');" />
<br />
<iframe id="rte">
</iframe>
</body>
</html>

TOP

Back Forum