Computer Hope

Internet & Networking => Web design => Topic started by: frank fazzio on December 27, 2007, 03:57:48 PM

Title: Can't understand this href
Post by: frank fazzio on December 27, 2007, 03:57:48 PM
I'm trying to teach myself HTML and Javascript.  The basic books seems to skip over some "basics."  I've spent the last 4 hours with my nose in reference books and in search engines trying to find out what the "#" in the following link tag means.  I read this in one of my instructional books and I am just plain stuck.  Here it is
          <a id="products" href="#">
Everything else in this anchor/link tag is clear to me but I cannot figure out what the "#" refers to.  There are no anchors set within this HTML page. Is this some sort of shorthand for a standard location within the same document/page?

Stumped!
Frank Fazzio
Title: Re: Can't understand this href
Post by: michaewlewis on December 27, 2007, 04:34:31 PM
# is just a filler. It doesn't mean anything. You usually put it in an href when you are doing some sort of scripting with javascript and the script is doing the relocation or other work. I've used the # when using an onmouseover, or onclick, or other onmouse events.
Title: Re: Can't understand this href
Post by: mitz on January 03, 2008, 03:11:23 PM
I think it looks like a substitue for where you put the url to link to Products. 

<a id="products" href="http://www.site/product catalog.htm">
Products[/url]
#=url ???
Maybe thats what it means. What a terrible book not explaining things properly.
Title: Re: Can't understand this href
Post by: squall_01 on January 04, 2008, 03:29:46 AM
I don't know javascript but I did take html.  ummmm..... <A href=''"> Link name[/url]  the id tag is if someone runs the mouse over it and wants to know what it is.  The # is probably a place holder something that your to supposed to have put your own link there. 
Title: Re: Can't understand this href
Post by: michaewlewis on January 04, 2008, 10:59:44 AM
# is just a filler. It doesn't mean anything. You usually put it in an href when you are doing some sort of scripting with javascript and the script is doing the relocation or other work. I've used the # when using an onmouseover, or onclick, or other onmouse events.

That's the answer. ok.... ::)
Title: Re: Can't understand this href
Post by: CBMatt on January 06, 2008, 04:53:58 PM
You guys are just going to confuse the OP.  michaewlewis is on the right track...it typically just acts as filler.  If you use that in place of a URL, it won't do anything.  Well, aside from redirecting you to the top of the page.  Technically, that's what it is designed to do: redirect viewers to different sections of the page.  Because # alone is empty, it redirects to the top.  However, you can control its actions by applying name anchors throughout your page.  For example, if you have a music section on your page, you can make something like this...

<a name="music">My Music[/url]



Then, when someone clicks on the below link...

<a href="#music">LINK[/url]

...it will automatically redirect them to the My Music section.  It can be quite useful.



When it comes to needing non-linking filler, I prefer using javascript: void(0); rather than #.