
December 19th, 2005, 04:16 PM
|
|
Registered User
|
|
Join Date: Oct 2005
Posts: 28
Time spent in forums: 6 h 5 m 43 sec
Reputation Power: 0
|
|
WYSIWYG - Font
Hi,
I've created a font changing feature in my website, it can change the font, but it cant display the current font (for example, you have two pieces of text in different fonts (e.g. hello hi) your cursor is in the text: hi, and you move the cursor to the text: hello, the selection box needs to change to the selected font, but i cant make a way of doing it)
Code:
var fArray = new Array();
function add(string)
{
var aia = fArray.length // aia stands for array item amount
var naia = aia++ // n stands for new
fArray[(eval(naia))] = string
}
function displayFonts()
{
var a=dlgHelper.fonts.count; // dlgHelper is an object in the document, it just gives the script the information it needs to display the fonts.
for (i = 1;i < a;i++)
{
add(dlgHelper.fonts(i));
}
displayFonts2();
}
function displayFonts2()
{
var oSelect = document.getElementById("oSelect")
for (i = 0; i < dlgHelper.fonts.count; i++)
{
var oOption = document.createElement("OPTION");
oOption.text = fArray[i]
oOption.Value = i
oSelect.add(oOption);
}
}
function ChangeHeading()
{
<!-- // -- To Be Made -- // -->
}
function ChangeFont()
{
var root = document.iFrame.document
var oSelect = document.getElementById("oSelect");
var sSelection = oSelect.options[oSelect.selectedIndex].text;
root.execCommand("FontName", false, sSelection);
}
That all works  , but then this doesn't, but it should
Code:
function showFont()
{
var curFnt=document.iFrame.document.queryCommandValue( "fontname")
var oSelect=document.getElementById("oSelect")
var i;
for (i in fArray)
{
var arrTxt=fArray[i]
if (arrTxt==curFnt) oSelect.value=i; break;
}
}
|