SitePoint Sponsor

User Tag List

Results 1 to 9 of 9

Thread: href="#" ~vs~ ?

  1. #1
    SitePoint Zealot jammo's Avatar
    Join Date
    Dec 2003
    Location
    el paso tx
    Posts
    119
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    href="#" ~vs~ ?

    hello.
    newbie here << kidna sorta >>

    i've got a javascript on my page.
    a mouseover effect takes place when visitor goes to navigate.

    the code is here at DynamicDrive @ http://dynamicdrive.com/dynamicindex5/popinfo.htm

    the code in question is this:
    Code:
    <a href="#" title="jammo" onMouseOver="stm(Text[1],Style[1])" onMouseOut="htm()">
    should I or should I NOT us this: <a href="#"

    i remember reading elsewhere what using <a href="#" is not proper standard and ishould use something else.
    i think it was (script;) but that produces and error.

  2. #2
    SQL Consultant gold trophysilver trophybronze trophy
    r937's Avatar
    Join Date
    Jul 2002
    Location
    Toronto, Canada
    Posts
    39,215
    Mentioned
    58 Post(s)
    Tagged
    3 Thread(s)
    the definitive article on this is

    Links & JavaScript Living Together in Harmony
    rudy.ca | @rudydotca
    Buy my SitePoint book: Simply SQL
    "giving out my real stuffs"

  3. #3
    SitePoint Zealot jammo's Avatar
    Join Date
    Dec 2003
    Location
    el paso tx
    Posts
    119
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    @r937
    thanks for the link, but it wasn't as helpful as i had hoped.

    if you or anyone else has the time, go ahead and visit the DynamicDrive link i posted above ( http://dynamicdrive.com/dynamicindex5/popinfo.htm ) and download the .ZIP file.
    make a page with it and see what i mean.

    this particular script is NOT a pop-up window.
    it is a tiny-pop-up-DHTML-tip.


    Quote Originally Posted by r937
    the definitive article on this is

    Links & JavaScript Living Together in Harmony

  4. #4
    Beer Monster -Ox's Avatar
    Join Date
    Apr 2003
    Location
    sowth afreeka
    Posts
    374
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    the only irritating thing that I find about the <a href="#" is that it takes you to the top of the page again, I tend to use the follwoing code when I am calling a JS function via onclick, onmouseover, etc using and href:

    HTML Code:
    <a href="void(0)" title="jammo" onMouseOver="stm(Text[1],Style[1])" onMouseOut="htm()">click it</a>
    so far for me I have never had an error, what it does it

    Hope this helps a bit
    My postings are a natural product.
    The slight variations in spelling and grammar enhance its
    individual character and beauty and in no way are to be
    considered flaws or defects - http://www.guinnesspig.net

  5. #5
    gingham dress, army boots... silver trophy redux's Avatar
    Join Date
    Apr 2002
    Location
    Salford / Manchester / UK
    Posts
    4,838
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    HTML Code:
    href="void(0)"
    is actually quite wrong. if you MUST use javascript in the href, you need to qualify it like so
    HTML Code:
    href="javascript:void(0)"
    and, if i'm not mistaken, this is non-standard and not advised, as clients that do not support javascript (e.g. lynx) will treat it as a broken link.

    in an ideal world, you'd apply the javascript to something other than the A element if it's not a proper link...but IE (and possibly others) doesn't support that.

    if you can get away with it, simply omit the href altogether. if not, # is the lesser of all evils. make sure that your javascripts have a "return false" to stop browsers that do process the javascript behaviours from processing them AND jumping to the top of the document.
    re·dux (adj.): brought back; returned. used postpositively
    [latin : re-, re- + dux, leader; see duke.]
    WaSP Accessibility Task Force Member
    splintered.co.uk | photographia.co.uk | redux.deviantart.com

  6. #6
    SitePoint Zealot jammo's Avatar
    Join Date
    Dec 2003
    Location
    el paso tx
    Posts
    119
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    ok, in my code, i do NOT need to use javascript in the href="" tag.

    i just didn't want it to be a link to another page, therefore i wanted to put href="#" in it. but as you pointed out, it takes me back to the top of the page.

    if you view my page (http://jammo.net), you can see how the navigation works.
    place your cursor over the first SQUARE located beneath the letter O in jammO.net


    to make things simple, i did this:
    <a href="#" onMouseOver="stm(Text[0],Style[1])" onMouseOut="htm()" style="cursor: default;">

    since the cursor wont be turning into a hand, to indicate a link is active, im hoping no one will click and ill leave href="#" as it is.

    Quote Originally Posted by redux
    HTML Code:
    href="void(0)"
    is actually quite wrong. if you MUST use javascript in the href, you need to qualify it like so
    HTML Code:
    href="javascript:void(0)"
    MANY MANY thanks for your tips and assistance redux
    Last edited by jammo; Dec 18, 2003 at 15:22. Reason: forgot to thank redux; THANKS!!

  7. #7
    Beer Monster -Ox's Avatar
    Join Date
    Apr 2003
    Location
    sowth afreeka
    Posts
    374
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    what about trying <img src="pic.gif" onMouseOver="stm(Text[0],Style[1])" onMouseOut="htm()">
    My postings are a natural product.
    The slight variations in spelling and grammar enhance its
    individual character and beauty and in no way are to be
    considered flaws or defects - http://www.guinnesspig.net

  8. #8
    SitePoint Zealot jammo's Avatar
    Join Date
    Dec 2003
    Location
    el paso tx
    Posts
    119
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    thank you thank you thank you thank you thank you thank you thank you thank you.

    that solved all my issues regarding the href="#" thingie.

    you gotta see it in action: www.jammo.net

    Quote Originally Posted by -Ox
    what about trying <img src="pic.gif" onMouseOver="stm(Text[0],Style[1])" onMouseOut="htm()">

  9. #9
    Beer Monster -Ox's Avatar
    Join Date
    Apr 2003
    Location
    sowth afreeka
    Posts
    374
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Looking great! glad I could help
    My postings are a natural product.
    The slight variations in spelling and grammar enhance its
    individual character and beauty and in no way are to be
    considered flaws or defects - http://www.guinnesspig.net


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
  •