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();
}
}
{
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"
}
};
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.