SitePoint Sponsor

User Tag List

Results 1 to 13 of 13

Hybrid View

  1. #1
    SitePoint Zealot litmania_com's Avatar
    Join Date
    Feb 2001
    Location
    London
    Posts
    186
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Adding ALT tag within this Javascript ?

    I wish to add an ALT command to the following Javascript.

    I have tried it with a ' /' /" or just " but always get an error message. I wish to add the ALT command to the URL link as is months [9].

    How do I do it?

    Also, I don't suppose there's any way of adding a mouseover command to the link while it is within this Javascript is there?

    Thanks

    Code:
    <SCRIPT LANGUAGE="JavaScript">
    
    <!-- Begin
    var months=new Array(13);
    months[1]="this New Year!";
    months[2]="this February!";
    months[3]="this March";
    months[4]="this Spring";
    months[5]="this Spring";
    months[6]="this June";
    months[7]="this summer";
    months[8]="this August <a href=http://www.augustwebsite.com August</a>";
    months[9]="this <a href=http://www.septemberwebsite.com September</a>";
    
    var time=new Date();
    var lmonth=months[time.getMonth() + 1];
    document.write(lmonth);
    
    // End -->
    </SCRIPT>
    Nadeem Azam
    Litmania.com Inc.

    Free promotion - check out this 1:1 banner exchange
    Dot com domains - the world's most prestigious domain names for sale

  2. #2
    ********* obeah makeda's Avatar
    Join Date
    Jun 2001
    Location
    rollin' on dubs
    Posts
    492
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    i wasn't sure what you meant by the ALT command but i did notice that some of your links weren't closed. instead of:

    months[8]="this August <a href=http://www.augustwebsite.com August</a>";
    months[9]="this <a href=http://www.septemberwebsite.com September</a>";


    try:

    months[8]="this August <a href=\"http://www.augustwebsite.com\">August</a>";
    months[9]="this <a href=\"http://www.septemberwebsite.com\"> September</a>";

  3. #3
    ********* obeah makeda's Avatar
    Join Date
    Jun 2001
    Location
    rollin' on dubs
    Posts
    492
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    i just saw the second part of your question. you should be able to add a mouseover event to your code, no problem. it should work with IE but i don't know about netscape 4.7. in your javascript, define the function you want to fire when you mouseover your link. Then just add your code to the array. by the way, you might want to bundle your array code into a function

    <script language="javascript">

    function mouseOverLink() {
    alert("The mouseover event works!");
    }

    function theArray() {
    var months=new Array(13);
    months[1]="this New Year!";
    months[2]="this February!";
    months[3]="this March";
    months[4]="this Spring";
    months[5]="this Spring";
    months[6]="this June";
    months[7]="this summer";
    months[8]="this August <a href=\"http://www.augustwebsite.com\" onMouseOver=\"mouseOverLink\">August</a>";
    months[9]="this <a href=\"http://www.septemberwebsite.com\" onMouseOver=\"mouseOverLink\"> September</a>";

    var time=new Date();
    var lmonth=months[time.getMonth() + 1];
    document.write(lmonth);
    }
    </script>

  4. #4
    SitePoint Zealot litmania_com's Avatar
    Join Date
    Feb 2001
    Location
    London
    Posts
    186
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Ooops, sorry. I meant TITLE= instead of ALT=

    Works fine now, with the changes suggested in your first posting. The second script posted by Makeda, with the onmouseover enhancement doesn't display anything at all in my browser. I have IE 5.0

    Know what's wrong?

    Also, is there any way of having a seperate onmouseover description for each link, i.e. a different one each month?

    Thanks for all your help. I appreciate it
    Nadeem Azam
    Litmania.com Inc.

    Free promotion - check out this 1:1 banner exchange
    Dot com domains - the world's most prestigious domain names for sale

  5. #5
    ********* obeah makeda's Avatar
    Join Date
    Jun 2001
    Location
    rollin' on dubs
    Posts
    492
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    really? it kind of works in mine. i should have said this before but by bundling your array into a function, we need to fire it from somewhere. so for example, i would keep all of the javascript in the <head> section and then fire in from an onLoad event. for example:

    <body onLoad="theArray();">

    this will fire your original function. regarding the mouseover event, i noticed that when i ran this it says that i haven't defined the mouseOverLink event (which we have). i will have to think about this one but if you put the actions inline, it works fine:

    months[9]="this <a href=\"http://www.septemberwebsite.com\" onMouseOver=\"alert('mouseover event is firing!!');\"> September</a>";


    by the way, for the title, just add that in too.

    months[9]="this <a href=\"http://www.septemberwebsite.com\" onMouseOver=\"alert('mouseover event is firing!!');\" title=\"September\"> September</a>";

    so if you wanted different things to happen in your mouseover events just spell them out inline for now. i'm going to think about why it doesn't recognize that function.

  6. #6
    SitePoint Zealot litmania_com's Avatar
    Join Date
    Feb 2001
    Location
    London
    Posts
    186
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    You are an angel Makeda. Thanks VERY much for your help. It is perfect as it is.

    The onmouseover command works.

    However, the onmouseover command I wanted to use was to show a description of the link the status bar. I have tried various guises of the following code, but to no avail:
    Code:
    onMouseOver="window.status='Go here to visit Israel';return true"
    e.g.:
    Code:
    months[9]="this <a href=\"http://www.septemberwebsite.com\" 
    onMouseOver=\"window.status=\'Go here to visit Israel\';return true\" title=\"September title\"> September</a>";
    The error message is 'unterminated message string'.

    What am I doing wrong?

    Thank you.
    Nadeem Azam
    Litmania.com Inc.

    Free promotion - check out this 1:1 banner exchange
    Dot com domains - the world's most prestigious domain names for sale

  7. #7
    ********* obeah makeda's Avatar
    Join Date
    Jun 2001
    Location
    rollin' on dubs
    Posts
    492
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    o.k. problem solved. i forgot that when you add event handlers to the <a> tag, you can't use the href attribute, so this is what you need to do:

    months[9]="this <a onMouseOver=\"window.status='Go here to visit Israel'; return true;\" onCLick=\"location.href='http://www.septemberwebsite.com'\" title=\"September\"> September</a>";

    P.S. I've seen you tearing up the US in some of your posts. I'm from the US. I trust that by helping you out here, we're operating on a level of mutual respect. If this is not the case, please let me know. peace.

  8. #8
    SitePoint Zealot litmania_com's Avatar
    Join Date
    Feb 2001
    Location
    London
    Posts
    186
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Makeda - I haven't intended to tear up America, least of all at this sensitive time.

    All my assertions in the other part of SP's forum have been backed up with factual evidence and could, if the US government opened its eyes and ears, prove beneficial for the world's greatest superpower in realising how it is perceived by millions if not billions of people the world over.

    I like America. I like Americans and have more American friends here in London than I do British ones, even though I was born and bred in Britain and have never even been to the States

    Anyway, back to the scripting (less controversial and less interesting ) : the script works perfectly now. Only one final remaining problem: it doesn't display the hotlink with underlined/different color text. It doesn't look clickable. See the very top of this page.

    How do I make the following code, which you have so kindly created, look more like a conventional URL link:
    Code:
    months[9]="this <a onMouseOver=\"window.status='Go here to visit Israel'; return true;\"
    onCLick=\"location.href='http://www.septemberwebsite.com'\" title=\"September\"> September</a>";
    Nadeem Azam
    Litmania.com Inc.

    Free promotion - check out this 1:1 banner exchange
    Dot com domains - the world's most prestigious domain names for sale

  9. #9
    ********* obeah makeda's Avatar
    Join Date
    Jun 2001
    Location
    rollin' on dubs
    Posts
    492
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    right on.

    anyway, you can handle this in one of two ways. you can either include href="#":

    months[9]="this <a href=\"#\" onMouseOver=\"window.status='Go here to visit Israel'; return true;\"
    onCLick=\"location.href='http://www.septemberwebsite.com'\" title=\"September\"> September</a>";

    or you can attactch a css style:

    months[9]="this <a onMouseOver=\"window.status='Go here to visit Israel'; return true;\"
    onCLick=\"location.href='http://www.septemberwebsite.com'\" title=\"September\" style=\"color: blue; text-decoration: underline;\"> September</a>";

    You can also add an onMouseOut event to your code to neutralize the status bar after someone is no longer hovering over your link. it should look the same as the onMouseOver event only set window.status=''.

    one more thing, remember to test this with different browsers. it should all work with IE but other browsers aren't as supportive.

    peace.
    Last edited by makeda; Sep 17, 2001 at 19:20.

  10. #10
    SitePoint Zealot litmania_com's Avatar
    Join Date
    Feb 2001
    Location
    London
    Posts
    186
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I feel guilty about this and am sorry to bother you again, but neither of the two lines of coding you have kindly provided work.

    Get an error message: "unterminated string constant". I'm using IE 5.0.

    Do you know what's wrong please?

    Peace!
    Nadeem Azam
    Litmania.com Inc.

    Free promotion - check out this 1:1 banner exchange
    Dot com domains - the world's most prestigious domain names for sale

  11. #11
    ********* obeah makeda's Avatar
    Join Date
    Jun 2001
    Location
    rollin' on dubs
    Posts
    492
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    the line of code that i posted i have tested(w/IE5.5) and it works fine. double check all of your syntax. make sure that all of your quotation marks have been escaped. Also, you don't need the style and the href so i would say just add the href=\"#\".

    Also, isolate your code. Create a temporary webpage just to test these functions. If this still doesn't work post a link to your page and i will check it out.

  12. #12
    ********* obeah makeda's Avatar
    Join Date
    Jun 2001
    Location
    rollin' on dubs
    Posts
    492
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    o.k. i have tested this and it works. when i debugged your code, i think that i found the problem. you had a line break in your code. the code needs to be entered as one continuous string with no line breaks (ie don't hit the return key when you're entering this and make sure your word wrap isn't doing anything weird) or it will give you the error that you were getting. so if you cut and paste directly from the webpage it will probably put in line breaks. make sure that you remove them and it will work.

    months[9]="this <a onMouseOver=\"window.status='Go here to visit Israel'; return true;\" onCLick=\"location.href='http://www.septemberwebsite.com'\" title=\"September\" style=\"color: blue; text-decoration: underline; cursor: hand; \"> September</a>";

  13. #13
    SitePoint Zealot litmania_com's Avatar
    Join Date
    Feb 2001
    Location
    London
    Posts
    186
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Makeda - works great now! Thank you, thank you, thank YOU! People like you restore my faith in humanity.

    I wish you all the best
    Nadeem Azam
    Litmania.com Inc.

    Free promotion - check out this 1:1 banner exchange
    Dot com domains - the world's most prestigious domain names for sale


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
  •