alt tags in images

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Rick

    alt tags in images

    how would you create a function in the following script that would
    change the alt description of the image via a mouseover event. See
    end of script. Thanks in advance.

    RICK

    <script language="JavaS cript">
    var i = 1;
    banner1= new Image();
    banner1.src = "image1.jpg ";
    banner2= new Image();
    banner2.src = "image2.jpg ";



    var links = new Array

    links[1] = "http://www.centerforpl antconservation .org/testing/image1.jpg"
    links[2] = "http://www.centerforpl antconservation .org/testing/image2.jpg"

    function loadBanner(){

    var time= new Date();
    hours= time.getHours() ;
    mins= time.getMinutes ();
    secs= time.getSeconds ();
    closeTime=hours *3600+mins*60+s ecs;

    // Change this number to increase decrease the rotation speed
    closeTime+=3;

    Timer();

    }

    function Timer(){
    var time= new Date();
    hours= time.getHours() ;
    mins= time.getMinutes ();
    secs= time.getSeconds ();
    curTime=hours*3 600+mins*60+sec s
    if (curTime>=close Time){
    if (i < 5){
    i++;
    document.banner .src = eval("banner" + i +
    ".src");
    }
    else{
    i = 1;
    document.banner .src = eval("banner" + i +
    ".src");
    } loadBanner();
    }
    else{
    window.setTimeo ut("Timer()",10 00)}

    }

    function clickLink(){
    top.location = links[i]
    }

    function altimage() {
    var ???????
    ????????????
    }


    </script>
  • Evertjan.

    #2
    Re: alt tags in images

    Vjekoslav Begovic wrote on 08 aug 2003 in comp.lang.javas cript:[color=blue]
    > To change alt attribute of image:
    >
    > myImage.setAttr ibute("alt", "MyAltText" );[/color]

    Slightly OT-ing the OP:

    <img src="..."
    alt="this is my standard alt text"
    standard="this is my standard alt text"
    alternative="th is is my alternative alt text"
    onclick="this.a lt=(this.alt==t his.alternative )?
    this.standard:t his.alternative "[color=blue]
    >[/color]

    IE6 tested

    --
    Evertjan.
    The Netherlands.
    (Please change the x'es to dots in my emailaddress)

    Comment

    • Richard Cornford

      #3
      Re: alt tags in images

      "Evertjan." <exjxw.hannivoo rt@interxnl.net > wrote in message
      news:Xns93D168C FBE82Aeejj99@19 4.109.133.29...
      <snip>[color=blue]
      > Slightly OT-ing the OP:
      >
      > <img src="..."
      > alt="this is my standard alt text"
      > standard="this is my standard alt text"
      > alternative="th is is my alternative alt text"
      > onclick="this.a lt=(this.alt==t his.alternative )?
      > this.standard:t his.alternative "[color=green]
      > >[/color]
      > IE6 tested[/color]

      It is very questionable whether adding your own HTML attributes is a
      good idea (it should certainly make validating a page against a standard
      HTML DTD troublesome).

      However, if this technique is used, it is worth mentioning that a number
      of browsers do not follow IE in making these attributes into named
      properties of the element. They are often (but not always) made
      available as attribute nodes so slightly wider browser support can be
      achieved by exclusively using the - getAttribute - method of the element
      when accessing this type of made up HTML attribute.

      Obviously support for providing this type of additional data can be
      increased to 100% of JavaScript capable/enabled browsers merely by
      defining the data in the JavaScript code (in whatever data structure
      suites the problem).

      The original question seems to be an attempt to use the ALT attribute as
      a vehicle for tool-tip type information. This is widely considered to be
      an inappropriate use of the ALT attribute, encouraged by the fact that
      some user agents present the contents of the ALT attribute in a tool-tip
      style pop-up box. The regulars on HTML groups will usually try to
      convince people that the TITLE attribute is the correct vehicle for
      tool-tip type information and that the ALT attribute should be a text
      alternative to the image, so it would only make sense to change the ALT
      attribute text if the image was also swapped.

      Richard.


      Comment

      Working...