Getting SPAN fontSize attribute

T

toddaa

I'm sorry if this has previously asked and answered. I have been
searching for a while and have come up empty.

I am trying to write a function which will return the font size
attribute for the current location of the cursor in an editable iframe.
Unfortunately, queryCommandValue doesnt seem to be working. Instead
of using the FONT tag everything is being converted to SPAN in order to
set the font size by points instead of the seven browser sizes. So
basicly I need to return the font size that has been set with the style
property of the SPAN tag.

I started down a great path using getElementsByTagName("SPAN"), but
that ended up giving me the font size of every SPAN in the iframe
element. If there was a way to reference where the cursor is currently
at that might be enough to make this work, but I dont know of such a
thing. Here's the code for what I was working on:

var allSpans = ifrmSlide.document.getElementsByTagName("SPAN");
for(i=0;i<allSpans.length;i++){
alert(allSpans.style.fontSize);
}

Let me know if there are any suggestions or questions. I really
appreciate it.
 
A

alu

I'm sorry if this has previously asked and answered. I have been
searching for a while and have come up empty.

I am trying to write a function which will return the font size
attribute for the current location of the cursor in an editable iframe.
Unfortunately, queryCommandValue doesnt seem to be working. Instead
of using the FONT tag everything is being converted to SPAN in order to
set the font size by points instead of the seven browser sizes. So
basicly I need to return the font size that has been set with the style
property of the SPAN tag.

I started down a great path using getElementsByTagName("SPAN"), but
that ended up giving me the font size of every SPAN in the iframe
element. If there was a way to reference where the cursor is currently
at that might be enough to make this work, but I dont know of such a
thing. Here's the code for what I was working on:

var allSpans = ifrmSlide.document.getElementsByTagName("SPAN");
for(i=0;i<allSpans.length;i++){
alert(allSpans.style.fontSize);
}

Let me know if there are any suggestions or questions. I really
appreciate it.


Could be as simple as
<span style="font-size:12pt"
onmouseover="theFunction(this.style.fontSize)">mouseover span</span>

-alu
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,744
Messages
2,569,484
Members
44,903
Latest member
orderPeak8CBDGummies

Latest Threads

Top