473,378 Members | 1,397 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,378 software developers and data experts.

Getting SPAN fontSize attribute

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[i].style.fontSize);
}

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

Nov 1 '05 #1
2 1901
alu

<to****@gmail.com> wrote in message
news:11**********************@z14g2000cwz.googlegr oups.com...
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[i].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)">mou seover span</span>

-alu
Nov 1 '05 #2

What you need is to have an event, mouseover, return the hovered node and
check if it's span or else and access its properties or such, in
mozilla/geckos/opera, you can do it from the function listener to the
event, attached to it, 1st arguement .target object, in IE is .srcElement:

function check(ev) {
aler(ev.target.nodeName) // to return the tag name
alert(srcElement.nodeName) // IE uses like so, as for Opera,
opera uses either
}

to change the fontSize, just do an ev.target.style.fontSize='12pt' or so.
Danny
Nov 1 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: Mike | last post by:
I´ve got a number of SPAN elements named "mySpan1", "mySpan2", "mySpan3" etc, and want to set their "style.display" to "inline". This works (only needs to work on IE5.5+): for (var x = 1; x <...
23
by: Mikko Ohtamaa | last post by:
From XML specification: The representation of an empty element is either a start-tag immediately followed by an end-tag, or an empty-element tag. (This means that <foo></foo> is equal to...
3
by: macgyver | last post by:
This is a strange question, and I think the answer is NO, but I am asking anyway. I am a member of a website which allows us to alter our member profiles. Using css in the middle of the profile...
4
by: jawolter | last post by:
I have text that is too long to nicely fit on a given page, so I want to add ellipses to the end that dynamicaly resize based on the person resizing the page width. If you hover it would show the...
5
by: ste.paoletti | last post by:
I have a problem with css I have a this xhtml code: <span> <span> <span/> <input type="radio"/> .... <span/> <input type="button" onclick ="var s=document.createElement('span');...
1
by: Fao, Sean | last post by:
I'm trying to set the title attribute on a CheckBox and I'm having some issues in ASP.NET 1.1. The title attribute in the following example is valid in HTML 4.01 Transitional: <input...
1
by: tshad | last post by:
I am running a program to put a captcha image on my string and am trying to make sure all the characters fit. The problem is the size seems to be wrong. What I am doing is starting from the...
7
by: mavigozler | last post by:
IE7 does not appear to set an event on contained text inside SPAN elements whose 'onclick', 'onmouseover', and 'onmouseout' events, defying the HTML recommendation. Firefox appears to conform. ...
6
by: Adam Risser | last post by:
Hi, I am writing a function to change the font-size but I am running into a snag. I cannot get the current font-size of the body. Here is a link to a simplified test case ...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.