Hey mensen,
Ik wil graag de focus op een iframe zetten in FF. Ik heb de volgende code:
Dan op de knop van Bold doe ik editor.ToggleBold();
Hij geeft nu wel focus in IE maar niet in FF. In de onderstaande documentatie staat:
Wat doe ik fout?
Ik wil graag de focus op een iframe zetten in FF. Ik heb de volgende code:
JavaScript:
Op de onload van de body doe ik editor = new Editor("iframe");1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
| function Editor(EditorID) { this.EditorId = EditorID; this.TheEditor = this.getIFrameDocument(); this.TheEditor.designMode = "On"; } Editor.prototype.getIFrameDocument = function() { if(document.getElementById(this.EditorId).contentDocument) return document.getElementById(this.EditorId).contentDocument; else return document.frames[this.EditorId].document; } Editor.prototype.ToggleBold = function() { this.TheEditor.execCommand("Bold", false, null); this.TheEditor.focus(); } |
Dan op de knop van Bold doe ik editor.ToggleBold();
Hij geeft nu wel focus in IE maar niet in FF. In de onderstaande documentatie staat:
Dus zou mijn code goed moeten gaan. Het Bold doen opzich, gaat goed.IE allows the focus() method to be used directly on an iframe. Technically, the focus method should be executed against the contentWindow. The following code fragment can be used to replace iframe.focus() and will work with IE and Mozilla.
document.getElementById("iframe").contentWindow.focus()
Wat doe ik fout?