Page 1 of 2 12 LastLast
Results 1 to 10 of 14

Thread: Mouseover = text

  1. #1
    Join Date
    Apr 2007
    Posts
    33
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Mouseover = text

    hi,
    basically i wold like it so that on a site i am upgrading if you hover your mouse over the image of a person then a mini portfolio appears on the side of them. See Image below:



    The one problem i have is that it is just 1 image. On this image are several people so i would like it to be ableot to mouseover these people and show a bit about them.
    Any help is appreciated.

  2. #2
    Join Date
    Jun 2005
    Location
    英国
    Posts
    11,876
    Thanks
    1
    Thanked 180 Times in 172 Posts
    Blog Entries
    2

    Default

    What you want is an image map. Have a look here.
    Twey | I understand English | 日本語が分かります | mi jimpe fi le jbobau | mi esperanton komprenas | je comprends français | entiendo español | tôi ít hiểu tiếng Việt | ich verstehe ein bisschen Deutsch | beware XHTML | common coding mistakes | tutorials | various stuff | argh PHP!

  3. #3
    Join Date
    Apr 2007
    Posts
    33
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    Ok cheers for the link thats what i wanted.
    One problem though. It allows me to set links on the areas i want but i wanted it as a onmouseover afffect where the text appears to the side with no clicking involed. Could anyone help me with this aspect of it.
    Cheers

  4. #4
    Join Date
    Jun 2005
    Location
    英国
    Posts
    11,876
    Thanks
    1
    Thanked 180 Times in 172 Posts
    Blog Entries
    2

    Default

    You can set onmouseover attributes on the <area>s just as if they were links.
    Twey | I understand English | 日本語が分かります | mi jimpe fi le jbobau | mi esperanton komprenas | je comprends français | entiendo español | tôi ít hiểu tiếng Việt | ich verstehe ein bisschen Deutsch | beware XHTML | common coding mistakes | tutorials | various stuff | argh PHP!

  5. #5
    Join Date
    Apr 2007
    Posts
    33
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    could you expand on that a bit please, or maybe a smple bit of code would help a lot cheers.

  6. #6
    Join Date
    Jun 2005
    Location
    英国
    Posts
    11,876
    Thanks
    1
    Thanked 180 Times in 172 Posts
    Blog Entries
    2

    Default

    Well, for example,
    Code:
    <area shape="rect" coords="0, 0, 50, 50" onmouseover="document.getElementById('myElement').firstChild.nodeValue = 'Some text';">
    Twey | I understand English | 日本語が分かります | mi jimpe fi le jbobau | mi esperanton komprenas | je comprends français | entiendo español | tôi ít hiểu tiếng Việt | ich verstehe ein bisschen Deutsch | beware XHTML | common coding mistakes | tutorials | various stuff | argh PHP!

  7. #7
    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 Twey View Post
    Well, for example,
    Code:
    <area shape="rect" coords="0, 0, 50, 50" onmouseover="document.getElementById('myElement').firstChild.nodeValue = 'Some text';">
    Still avoiding innerHTML like the plague, I see. Perhaps you should mention that, if you do it that way, you need to have at least a &nbsp; inside the id="myElement" element, and that you cannot insert rich HTML content without considerably more code. I know innerHTML isn't a part of any official standard, but as has been pointed out numerous times, it is here to stay and is the easiest and perhaps even the best (depending upon the situation) method for inserting content.

    At the very least, wentwooddownhill should also consider:

    Code:
    document.getElementById('myElement').innerHTML = 'Some text<br>More text'
    - John
    ________________________

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

  8. #8
    Join Date
    Jun 2005
    Location
    英国
    Posts
    11,876
    Thanks
    1
    Thanked 180 Times in 172 Posts
    Blog Entries
    2

    Default

    If I wanted a quick-and-dirty HTML parser with good support and couldn't be bothered to write my own, innerHTML would be my first port of call. In fact, I've used it fairly extensively (as in my typing text script). However, for something as simple as this, I see no call to break the standards and lose XHTML support for the script.
    Perhaps you should mention that, if you do it that way, you need to have at least a &nbsp; inside the id="myElement" element,
    Possibly I should have done, but that was only an example, and obviously needs to be adapted for the OP's markup (or have the OP's markup adapted for it). There's probably currently no element with an ID of "myElement" in the markup either.
    and that you cannot insert rich HTML content without considerably more code.
    wentwooddownhill said "text" so I didn't even consider this worth mentioning. Furthermore, it's not exactly "considerably" more code, especially if we use an element-builder function:
    Code:
    function buildElement(nodeName, attributes) {
      var v = document.createElement(nodeName);
      if(attributes)
        for(var x in attributes)
          if(attributes.hasOwnProperty(x))
            if(x !== "style")
              v[x] = x;
            else
              for(var y in attributes.style)
                if(attributes.style.hasOwnProperty(y))
                  v.style[y] = y;
      for(var i = 2; i < arguments.length; ++i)
        if(typeof arguments[i] === "string")
          v.appendChild(document.createTextNode(arguments[i]));
        else
          v.appendChild(arguments[i]);
      return v;
    }
    It becomes as simple as:
    Code:
    document.getElementById("myElement").appendChild(
      buildElement("span", {
        'id' : "mySpan",
        'style' : {
          'display' : "block",
          'background-color' : "red"
        }
      },
      "Some inner text")
    );
    Reflects the structure of the HTML fairly well, and is one heck of a lot neater than the horrible multi-line string that usually results from innerHTML.

    Of course, that's kind of irrelevant anyway; wentwooddownhill should really already have elements created, and just hide/show them using Javascript (by setting and unsetting the CSS display property).
    Last edited by Twey; 07-07-2007 at 11:56 AM.
    Twey | I understand English | 日本語が分かります | mi jimpe fi le jbobau | mi esperanton komprenas | je comprends français | entiendo español | tôi ít hiểu tiếng Việt | ich verstehe ein bisschen Deutsch | beware XHTML | common coding mistakes | tutorials | various stuff | argh PHP!

  9. #9
    Join Date
    Apr 2007
    Posts
    33
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    Cheers for the help. I already have div elements set up etc. Didnt want to cause an argument between you guys
    I will try that now, it all has to lie within the validation rules of w3

  10. #10
    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 wentwooddownhill View Post
    Cheers for the help. I already have div elements set up etc. Didnt want to cause an argument between you guys
    I will try that now, it all has to lie within the validation rules of w3
    Twey and I are old buddies. We disagree on certain things, but that doesn't detract from our friendship. We actually agree here in that, I too think you should use pre-existing content in divisions that are in their turn shown and unseen. This can be manipulated, as Twey stated, via each division's display style property.

    Should you decide to use innerHTML, their isn't a question of it validating unless your javascript code is sloppy and on the page.
    - 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
  •