Getting SPAN fontSize attribute

Discussion in 'Javascript' started by toddaa@gmail.com, Nov 1, 2005.

  1. Guest

    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.
    , Nov 1, 2005
    #1
    1. Advertising

  2. alu Guest

    <> wrote in message
    news:...
    > 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
    alu, Nov 1, 2005
    #2
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Fulio Open

    Can span include span?

    Fulio Open, Jun 26, 2009, in forum: HTML
    Replies:
    5
    Views:
    529
    dorayme
    Jun 26, 2009
  2. Stéphane Klein
    Replies:
    2
    Views:
    1,724
    John Nagle
    Mar 30, 2010
  3. Stefan Behnel
    Replies:
    0
    Views:
    470
    Stefan Behnel
    Mar 29, 2010
  4. Dan Bishop

    DataGrid (body only) contained in <span>...</span> tags

    Dan Bishop, Jun 7, 2004, in forum: ASP .Net Datagrid Control
    Replies:
    2
    Views:
    254
    Kilic Beg
    Jun 7, 2004
  5. Adam Risser

    Help with getting fontSize on body tag

    Adam Risser, Jun 8, 2007, in forum: Javascript
    Replies:
    6
    Views:
    102
Loading...

Share This Page