Pomoc - Szukaj - Użytkownicy - Kalendarz
Pełna wersja: Prosty edytor
Forum PHP.pl > Forum > Po stronie przeglądarki
Gibcio2008
Witam !
Mam pewien problem i nie wiem jak go rozwiązać. Zawartość pliku "editor.js" w którym tworzę element "script" i nadaje mu ścieżkę do istniejącego pliku "pl.js"

Kod
function Editor(id)
{
        this.id = id;
        this.objectId = id;
      
        this.path = "";
        this.css = "style.css";
        this.lang = "pl.js";

        this.init = function()
        {
                var div = document.createElement("div");
                div.innerHTML = this.htmlEditor();
              
                document.getElementById(this.id).parentNode.replaceChild(div, document.getElementById(this.id));
              
                this.frame = document.getElementById(this.id).contentWindow;
                this.frame.document.designMode = "on";
                this.frame.document.open();
                this.frame.document.close();
                this.frame.focus();
              
                var script = document.createElement("script");
                script.setAttribute("type", "text/javascript");
                script.setAttribute("src", "jscript/editor/locales/pl.js");
                document.getElementsByTagName("head")[0].parentNode.appendChild(script);
        }
      
        this.htmlEditor = function()
        {
                html = '';
                html += '<!DOCTYPE HTML>';
                html += '<html>';
                html += '<head>';
                html += '<link rel="stylesheet" style="text/css" href="'+this.path + this.css+'">';
                html += '</head>';
                html += '<body>';
                html += '<div class="buttons">';
                html += '<input type="submit" class="button" title="'+buttons.bold['info']+'" onClick="'+this.objectId+'.Command(\'Bold\')">';
                html += '</div>';
                html += '<iframe class="frame" name="'+this.id+'" id="'+this.id+'"></iframe>';
                html += '</body>';
                html += '</html>';
                return html;
        }
      
        this.Command = function(cmd, value)
        {
                this.frame = document.getElementById(this.id).contentWindow;
                this.frame.focus();
                this.frame.document.execCommand(cmd, false, value);
                this.frame.focus();
        }
}

Zawartość pliku "pl.js"
Kod
var buttons = {
        bold: {
                "name": "Pogrubienie",
                "info": "Pogrubia zaznaczony tekst"
        }
};

I w pliku "editor.js" chciałbym aby po najechaniu myszką nad przycisk wyświetliła się odpowiednia informacja, czyli: Pogrubia zaznaczony tekst, działa to tylko w tedy gdy zawartość pliku "pl.js" wklepię w plik "editor.js", proszę o pomoc, z góry dziękuje.
zaajcu
Może tak:

http://api.jquery.com/jQuery.getScript/
To jest wersja lo-fi głównej zawartości. Aby zobaczyć pełną wersję z większą zawartością, obrazkami i formatowaniem proszę kliknij tutaj.
Invision Power Board © 2001-2025 Invision Power Services, Inc.