Ver Mensaje Individual
  #6 (permalink)  
Antiguo 09/12/2003, 08:44
Avatar de epplestun
epplestun
 
Fecha de Ingreso: octubre-2001
Mensajes: 1.621
Antigüedad: 23 años, 4 meses
Puntos: 5
Aqui te dejo la parte de js, es una API muy sencilla.

Código PHP:
<script language="JavaScript">
    
/*
       +----------------------------------------------------------------------+
       | DikodeRTE v.0.0.1                                                    |
       +----------------------------------------------------------------------+
       | Copyright (c) 2001-2003 DIkode                                       |
       +----------------------------------------------------------------------+
       | This source file is subject to version 2.02 of the PHP license,      |
       | that is bundled with this package in the file LICENSE, and is        |
       | available at through the world-wide-web at                           |
       | php.net/license/2_02.txt.                                 |
       | If you did not receive a copy of the PHP license and are unable to   |
       | obtain it through the world-wide-web, please send a note to          |
       | [email][email protected][/email] so we can mail you a copy immediately.               |
       +----------------------------------------------------------------------+
       | Authors: Ivan Rodriguez Espada   <[email protected]>              |
       +----------------------------------------------------------------------+
    */
    /*
     * Inicializa el editor
     */
    
function start() {
        
document.getElementById('edit').contentWindow.document.designMode "on";
    }
    
    
/*
     * Indica el estilo que queremos dar a nuestra letra
     */
    
function estilo(estilo) { 
        switch(
estilo) {
            case 
"Bold":
                
document.getElementById('edit').contentWindow.document.execCommand("Bold"falsenull);
                break;
            case 
"Italic":
                
document.getElementById('edit').contentWindow.document.execCommand("Italic"falsenull);
                break;
            case 
"Underline":
                
document.getElementById('edit').contentWindow.document.execCommand("Underline"falsenull);
                break;
            case 
"Superscript":
                
document.getElementById('edit').contentWindow.document.execCommand("Superscript"falsenull);
                break;
            case 
"Subscript":
                
document.getElementById('edit').contentWindow.document.execCommand("Subscript"falsenull);
                break;
            case 
"Strikethrough":
                
document.getElementById('edit').contentWindow.document.execCommand("Strikethrough"falsenull);
                break;
            default: break;
        }
        
document.getElementById('edit').contentWindow.focus();
    }
    
    
/*
     * Genera una ventana Modal
     */
    
function VentanaMod(urlanchoalto) {
        var 
anchoVentana ancho;
        var 
altoVentana  alto;
        var 
izquierda = ((screen.width-anchoVentana)/2);
        var 
arriba    = ((screen.height-altoVentana)/2);
        
window.open(url'Enlace''width='+anchoVentana+',height='+altoVentana',left=' izquierda ',top=' arriba);
    }    

    
/*
     * Alinea el documento
     */
    
function alinear(opcion) {
        switch(
opcion) {
            case 
"Justifycenter":
                
document.getElementById('edit').contentWindow.document.execCommand("Justifycenter"falsenull);
                break;
            case 
"Justifyfull":
                
document.getElementById('edit').contentWindow.document.execCommand("Justifyfull"falsenull);
                break;
            case 
"Justifyleft":
                
document.getElementById('edit').contentWindow.document.execCommand("Justifyleft"falsenull);
                break;
            case 
"Justifyright":
                
document.getElementById('edit').contentWindow.document.execCommand("Justifyright"falsenull);
                break;
            default: break;
        }
        
document.getElementById('edit').contentWindow.focus();
    }
    
    
/*
     * Funciones de edicion
     */
    
function edicion(estilo) { 
        switch(
estilo) {
            case 
"Paste":
                
document.getElementById('edit').contentWindow.document.execCommand("Paste"falsenull);
                break;
            case 
"Copy":
                
document.getElementById('edit').contentWindow.document.execCommand("Copy"falsenull);
                break;
            case 
"Cut":
                
document.getElementById('edit').contentWindow.document.execCommand("Cut"falsenull);
                break;
            case 
"Undo":
                
document.getElementById('edit').contentWindow.document.execCommand("Undo"falsenull);
                break;
            case 
"Redo":
                
document.getElementById('edit').contentWindow.document.execCommand("Redo"falsenull);
                break;
            default: break;
        }
        
document.getElementById('edit').contentWindow.focus();
    }
    
    
/*
     * Funciones de listas
     */
    
function listas(estilo) { 
        switch(
estilo) {
            case 
"Insertorderedlist":
                
document.getElementById('edit').contentWindow.document.execCommand("Insertorderedlist"falsenull);
                break;
            case 
"Insertunorderedlist":
                
document.getElementById('edit').contentWindow.document.execCommand("Insertunorderedlist"falsenull);
                break;
            default: break;
        }
        
document.getElementById('edit').contentWindow.focus();
    }    
    
    
/*
     * Funciones de margen
     */
    
function margen(estilo) { 
        switch(
estilo) {
            case 
"Outdent":
                
document.getElementById('edit').contentWindow.document.execCommand("Outdent"falsenull);
                break;
            case 
"Indent":
                
document.getElementById('edit').contentWindow.document.execCommand("Indent"falsenull);
                break;
            default: break;
        }
        
document.getElementById('edit').contentWindow.focus();
    }

    
/*
     * Funciones de estilo de fuente
     */    
    
function select(selectname)    {
        var 
cursel document.getElementById(selectname).selectedIndex;
        if (
cursel != 0) {
            var 
selected document.getElementById(selectname).options[cursel].value;
            
document.getElementById('edit').contentWindow.document.execCommand(selectnamefalseselected);
            
document.getElementById(selectname).selectedIndex 0;
        }
        
document.getElementById('edit').contentWindow.focus();
    }
    
    
/*
     * Inserta una linea horizontal
     */
    
function linea() {
        
document.getElementById('edit').contentWindow.document.execCommand("Inserthorizontalrule"falsenull);
        
document.getElementById('edit').contentWindow.focus();
    }
    
    function 
codigo() {
        var 
html document.getElementById('edit').contentWindow.document.body.innerHTML;
        
document.enlace.HTML.value html;
    }
    
</script> 
Eso seria el JS.

Luego tan solo tienes que añadir un iframe de esta manera:

Código:
<body onLoad="start()">
<iframe id="edit" width="100%" height="400px"  frameborder="1"></iframe>
</body>
Ummmmmm cuando acabe de trabajar monto el editor y lo cuelgo por ahi con el code explicado a ve si os sirve de algo

Saludillos!!!
__________________
Usuario registrado de Linux #288725

Última edición por epplestun; 09/12/2003 a las 08:45