473,804 Members | 4,223 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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, queryCommandVal ue 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 getElementsByTa gName("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.docum ent.getElements ByTagName("SPAN ");
for(i=0;i<allSp ans.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 1930
alu

<to****@gmail.c om> wrote in message
news:11******** **************@ z14g2000cwz.goo glegroups.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, queryCommandVal ue 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 getElementsByTa gName("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.docum ent.getElements ByTagName("SPAN ");
for(i=0;i<allSp ans.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="th eFunction(this. style.fontSize) ">mouseover 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(srcElemen t.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
6037
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 < 20; x++) { document.all('mySpan'+x).style.display = "inline"; } But I don´t know how many SPAN elements there are, so I need to set x to a
23
4096
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 <foo/>) From XHTML specification:
3
5520
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 area allows one to overide the normal formatting of the entire page and truly customize it. But there is a span-style tag which gives an ugly blue background to certain text which I want to get rid of. This is the tag: <span...
4
23474
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 full text, using a title attribute I believe. It works for a div, but not a span... any ideas? Here's a snippet that I'm working on: <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"
5
3256
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'); this.previousSibling.firstChild.appendChild(s); "/>
1
3982
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 id="MyCheckBox" type="checkbox" title="ToolTip"> However, ASP.NET doesn't like it. No matter what I do, ASP.NET places my control inside of a span tag with the title attribute set in the
1
1533
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 rectangles' height + 1 (not sure why I would use that as a starting point) then I loop through subtracting the value by 1 until the size I get back from MeasureString is less than the rectangle width.
7
2346
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. Is that so?
6
7932
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 http://mustang.millersville.edu/~wstudent/cewing/mu/test.php You would think that it would alert 72.5% when you click the resize button, but it alerts nothing. If i add the style to the body tag (style="font-size: 72.5%;" ), then it works.
0
9706
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
10577
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10332
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10320
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
10077
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
5521
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5651
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4299
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
3
2991
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.