Results 1 to 9 of 9

Thread: Title problem in IE

  1. #1
    Join Date
    Nov 2008
    Posts
    5
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Title problem in IE

    Hi,

    I'm trying to show a tooltip in IE using the title attribute.

    The problem is the text is carried over to a new line not at the right positions, but arbitrary by IE.

    I found I can control this by replacing spaces with   in the text - title="test text..."

    The problem is this is not possible using JS :

    element.title = "test text...";

    is not working.

    Why is it not working ? How to resolve this problem ?

    Thanks

  2. #2
    Join Date
    Jul 2008
    Posts
    128
    Thanks
    0
    Thanked 17 Times in 16 Posts

    Default

    Try: element.title = "test\xA0text...";

  3. #3
    Join Date
    Nov 2008
    Posts
    5
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    This is not working.

  4. #4
    Join Date
    Mar 2005
    Location
    SE PA USA
    Posts
    30,495
    Thanks
    82
    Thanked 3,449 Times in 3,410 Posts
    Blog Entries
    12

    Default

    Please post a link to the page on your site that contains the problematic code so we can check it out.
    - John
    ________________________

    Show Additional Thanks: International Rescue Committee - Donate or: The Ocean Conservancy - Donate or: PayPal - Donate

  5. #5
    Join Date
    Nov 2008
    Posts
    5
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    It's an intranet site.

    But I'm testing with the following code :

    <html>
    <script type="text/javascript">
    function repl()
    {
    var str = "text&nbsp;text&nbsp;text&nbsp;text&nbsp;text&nbsp;text&nbsp;text&nbsp;text&nbsp;text&nbsp;text";
    document.getElementById("anch").title = str;
    }
    </script>
    <body>
    <a id="anch" title="text&nbsp;text&nbsp;text&nbsp;text&nbsp;text&nbsp;text&nbsp;text&nbsp;text&nbsp;text&nbsp;text">text<a/>
    </body>
    </html>

    As I explained if I set the title attribute directly in <a> the tooltip is on a single line as I want. But I need to set it using js and it is not working.

  6. #6
    Join Date
    Mar 2005
    Location
    SE PA USA
    Posts
    30,495
    Thanks
    82
    Thanked 3,449 Times in 3,410 Posts
    Blog Entries
    12

    Default

    Quote Originally Posted by clueful View Post
    Try: element.title = "test\xA0text...";
    Works here:

    Code:
    <html>
    <script type="text/javascript">
    function repl()
    {
    var str = "text2\xa0text2\xa0text2\xa0text2\xa0text2\xa0text2\xa0text2\xa0text2\xa0text2\xa0text2";
    document.getElementById("anch").title = str;
    }
    </script>
    <body>
    <a id="anch" onclick="repl();" title="text1&nbsp;text1&nbsp;text1&nbsp;text1&nbsp;text1&nbsp;text1&nbsp;text1&nbsp;text1&nbsp;text1&nbsp;text1">text<a/>
    </body>
    </html>
    - John
    ________________________

    Show Additional Thanks: International Rescue Committee - Donate or: The Ocean Conservancy - Donate or: PayPal - Donate

  7. #7
    Join Date
    Nov 2008
    Posts
    5
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    Yes, actually it works.

    Thank you very much !

  8. #8
    Join Date
    Nov 2008
    Posts
    5
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    Still one problem though :

    In Firefox it looks like \xa0 is working, but I try \x0a which should be new line and it is not working. Do you know some resolution ?

  9. #9
    Join Date
    Mar 2005
    Location
    SE PA USA
    Posts
    30,495
    Thanks
    82
    Thanked 3,449 Times in 3,410 Posts
    Blog Entries
    12

    Default

    That won't work, for the same reason that this won't make a new line in a title:

    HTML Code:
    <a title="Something that
    breaks on a line break">What?</a>
    It's filtered out. If IE does allow it, it is just a different way that it is handling the dynamically added title. FF is doing it as though it were hard coded.

    If you need more control over the tool tip than title will allow across browsers, use a tool tip script.

    One thing though, if the combined length of the title is great enough, it will wrap on a space in FF or IE:

    Code:
    var str = "text2\xa0text2\xa0text2 text2\xa0text2\xa0text2\xa0text2\xa0text2\xa0text2\xa0text2\xa0text2\xa0text2\xa0text2\xa0text2\xa0text2\xa0text2";
    Last edited by jscheuer1; 11-11-2008 at 04:30 PM. Reason: add info
    - John
    ________________________

    Show Additional Thanks: International Rescue Committee - Donate or: The Ocean Conservancy - Donate or: PayPal - Donate

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •