| 12
 3
 4
 5
 6
 7
 8
 9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 
 |  
[...]
  document.writeln('			<select id="formatblock_' + rte + '" onchange="selectFont(\'' + rte + '\', this.id);">');
  document.writeln('				<option value="">[Style]</option>');
  document.writeln('				<option value="<p class=\'titre\'>">Titre</option>');
  document.writeln('				<option value="<h1>">Heading 1 <h1></option>');
  document.writeln('				<option value="<h2>">Heading 2 <h2></option>');
  document.writeln('				<option value="<h3>">Heading 3 <h3></option>');
  document.writeln('				<option value="<h4>">Heading 4 <h4></option>');
  document.writeln('				<option value="<h5>">Heading 5 <h5></option>');
  document.writeln('				<option value="<h6>">Heading 6 <h6></option>');
  document.writeln('				<option value="<address>">Address <ADDR></option>');
  document.writeln('				<option value="<pre>">Formatted <pre></option>');
  document.writeln('			</select>');
 
[...]
 
function selectFont(rte, selectname) {
	//function to handle font changes
	var idx = document.getElementById(selectname).selectedIndex;
	// First one is always a label
	if (idx != 0) {
		var selected = document.getElementById(selectname).options[idx].value;
		var cmd = selectname.replace('_' + rte, '');
		alert('rteCommand('+rte+', '+cmd+', '+selected+', '+selectname+')');
		rteCommand(rte, cmd, selected);
		document.getElementById(selectname).selectedIndex = 0;
	}
}
 
[...]
 
function rteCommand(rte, command, option) {
	//function to perform command
	var oRTE;
	if (document.all) {
		oRTE = frames[rte];
	} else {
		oRTE = document.getElementById(rte).contentWindow;
	}
 
	try {
		oRTE.focus();
		alert('execCommand('+command+', '+option+')');
	  	oRTE.document.execCommand(command, false, option);
		oRTE.focus();
	} catch (e) {
//		alert(e);
//		setTimeout("rteCommand('" + rte + "', '" + command + "', '" + option + "');", 10);
	}
} | 
Partager