Firefox: set innerHTML of Marquee-Tag

Discussion in 'Javascript' started by uwe.braunholz@hotmail.de, May 19, 2006.

  1. Guest

    Hello,

    I want to set the text of a marqee dynamical. So I created the
    following code:
    ****snip****
    <style>
    #noticeMarquee
    {
    background-color:#ff00ff;
    color:#ffffff;
    display:none;
    padding: 2px;
    font-size:10pt;
    }
    </style>
    <script type="text/javascript">
    function showMarquee(text){

    var elem = document.getElementById("noticeMarquee");

    if(text==""){
    elem.style.display = "none";
    }
    else{
    elem.firstChild.innerHTML = text;
    elem.style.display = "block";
    }
    }
    </script>
    </head>
    <body>
    <marquee id="noticeMarquee"></marquee>
    <div onclick="showMarquee('this is the text')">clickme</div>

    ***snap***

    This works fine in IE, but Firefox does only display the box of the
    marquee, not the text I set it to.

    I tried it with innerText or adding childnodes and stuff like that. But
    it seems like firefox does not update the marquee.

    Hopefully someone can help me this this!

    Thank you!

    Regards,
    Uwe Braunholz
     
    , May 19, 2006
    #1
    1. Advertising

  2. wrote:


    > I want to set the text of a marqee dynamical.


    > function showMarquee(text){
    >
    > var elem = document.getElementById("noticeMarquee");
    >
    > if(text==""){
    > elem.style.display = "none";
    > }
    > else{
    > elem.firstChild.innerHTML = text;


    Why elem.firstChild.innerHTML, why not elem.innerHTML?

    But I am not sure DOM manipulation of marquee works, marquee support in
    Mozilla is a hack mostly meant to work for those pages where marquees
    are used in markup.

    --

    Martin Honnen
    http://JavaScript.FAQTs.com/
     
    Martin Honnen, May 19, 2006
    #2
    1. Advertising

  3. wrote :
    > Hello,
    >
    > I want to set the text of a marqee dynamical. So I created the
    > following code:
    > ****snip****
    > <style>
    > #noticeMarquee
    > {
    > background-color:#ff00ff;
    > color:#ffffff;
    > display:none;
    > padding: 2px;
    > font-size:10pt;


    Why do you need to use pt? Why not %tage or em? pt is best for print
    media, not for screen.

    W3C Quality Assurance tip for webmasters:
    Care With Font Size: Recommended Practices
    http://www.w3.org/QA/Tips/font-size#goodpractice

    "Do not specify the font-size in pt, or other absolute length units.
    They render inconsistently across platforms and can't be resized by the
    User Agent (e.g browser).
    Use relative length units such as percent or (better) em"



    > }
    > </style>
    > <script type="text/javascript">
    > function showMarquee(text){
    >
    > var elem = document.getElementById("noticeMarquee");
    >
    > if(text==""){
    > elem.style.display = "none";
    > }
    > else{
    > elem.firstChild.innerHTML = text;


    If you only want to set the text node, then you do not need innerHTML
    and you should use
    elem.firstChild.nodeValue = text;
    If you use innerHTML to change the text node, then you do not need to
    refer to the firstChild. Whatever you do, I don't see how or why you
    would need to use innerHTML to change the text node.

    > elem.style.display = "block";


    I do not understand the need to toggle the display from none to block
    and vice versa if there is a text node or not. It kinda makes no sense
    to me.

    > }
    > }
    > </script>
    > </head>
    > <body>
    > <marquee id="noticeMarquee"></marquee>
    > <div onclick="showMarquee('this is the text')">clickme</div>
    >
    > ***snap***
    >
    > This works fine in IE, but Firefox does only display the box of the
    > marquee, not the text I set it to.


    You have not provided sufficient amount of code to understand what
    you're doing actually in terms of webpage context. Giving an url would
    have been helpful.

    >
    > I tried it with innerText or adding childnodes and stuff like that. But
    > it seems like firefox does not update the marquee.
    >


    innerText is a MSIE-specific DOM attribute not supported by Firefox.
    innerText is not a W3C DOM attribute.

    > Hopefully someone can help me this this!
    >
    > Thank you!
    >
    > Regards,
    > Uwe Braunholz




    Complete example with explanations is available here:
    DHTML Demonstrations Using DOM/Style:Stock Ticker
    http://developer.mozilla.org/en/docs/DHTML_Demonstrations_Using_DOM/Style:Stock_Ticker

    Gérard
    --
    remove blah to email me
     
    Gérard Talbot, May 20, 2006
    #3
  4. Uwe Guest

    Thank you Martin and Gérard,

    i am sorry, if the sample is a bit tiny. But thats what I acctually do:
    I want to call the function (showMarquee) from another frame to set a
    dynamical-read text to the marquee. This is meant to be some kind of
    "notice trigger". Thats why it is display none, if there is no text to
    display.

    Sorry for my bad sample. I did not remove the firstChild while
    preparing my sample. With that I tried to set the text of an innertag.

    Unfortunately the nodeValue does not change a thing in Firefox. It
    won't display the text anyway.

    Perhaps there is another solution (without using a tiker-js).

    Thank you!
    Uwe
     
    Uwe, May 23, 2006
    #4
  5. wrote:

    > <style>


    The required `type' attribute is missing:

    <style type="text/css">

    > #noticeMarquee
    > {
    > background-color:#ff00ff;
    > color:#ffffff;


    background-color:#f0f; /* or fuchsia */
    color:#fff; /* or white */

    > display:none;
    > padding: 2px;
    > font-size:10pt;


    `pt' is a unit of length suited for printouts, not for the screen; what is
    displayed large enough with your _font_ resolution (Windows default for
    1024x786: 96 ppi) may be unreadable or huge for other people. Use `%',
    `em' or `px' instead. In that order of preference, because `px' prevents
    the text from being scaleable in IE < 7 (a bug).

    See also: [de] http://dciwam.de/faq/gute-websites/einheit-pt

    > }
    > </style>
    > <script type="text/javascript">
    > function showMarquee(text){
    >
    > var elem = document.getElementById("noticeMarquee");


    <URL:http://pointedears.de/scripts/test/whatami#inference>

    > if(text==""){
    > elem.style.display = "none";
    > }
    > else{
    > elem.firstChild.innerHTML = text;


    `innerHTML' is proprietary, so you are mixing two DOMs here,
    which is unwise at best. Firefox supports the `textContent'
    property of W3C DOM Level 3 Core, DOM Level 2-conforming UAs
    support the nodeValue property of a Node object.

    See also: <URL:http://pointedears.de/scripts/dhtml.js>

    > [...]
    > <marquee id="noticeMarquee"></marquee>


    I go with Martin's assessment. The `marquee' element is proprietary.
    It creates invalid HTML, and should not be scripted, or used at all.

    <URL:http://validator.w3.org/>


    PointedEars

    P.S.
    de.comp.lang.javascript exists. (If you want to subscribe, please
    read news:de-newusers-infos/einleitung/
    first.
    --
    The German psychs, the German authorities, the German secret service agents
    are [...] fanatics, they are insane and known of persecuting innocent people
    and Scientologists. -- "The only real Barbara Schwarz", dsw.scientology,
    <>
     
    Thomas 'PointedEars' Lahn, May 25, 2006
    #5
    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. shruds
    Replies:
    1
    Views:
    829
    John C. Bollinger
    Jan 27, 2006
  2. The Devil's Advocate©

    Reversing a marquee tag

    The Devil's Advocate©, Oct 11, 2004, in forum: HTML
    Replies:
    22
    Views:
    2,345
    Sentient Fluid
    Oct 23, 2004
  3. Replies:
    8
    Views:
    832
  4. Tony

    Marquee For Firefox

    Tony, Dec 10, 2007, in forum: HTML
    Replies:
    65
    Views:
    11,606
    dorayme
    Dec 14, 2007
  5. jbonifacejr
    Replies:
    4
    Views:
    3,266
    Neredbojias
    Feb 5, 2008
Loading...

Share This Page