...

View Full Version : Newbie here, simple question I think...



grindy
11-30-2005, 12:36 AM
Hi all,

Here's some code that contains a part that I don't understand and that I haven't been able to find an explaination for.

In this code for a simple list, I don't understand the usage of the "#". I've gone to several forums and the W3 school page to search, but LOL you can't search for #.
What does the # stand for here?

<ul id="navigation">
<li id="youarehere"><a href="#">Home</a></li>
<li><a href="#">Products</a></li>
<li><a href="#">Services</a></li>
<li><a href="#">Contact Us</a></li>
</ul>

2reikis
11-30-2005, 12:48 AM
http://www.w3.org/TR/REC-html40/intro/intro.html#fragment-uri

The link above has some information on fragment identifiers. The pound sign (#) is used to identify a jump to a pre-defined section of a page rather than displaying the page from the top. Usually, the form used is (/somepage.htm#jump_here). In the case of the code you included in your post, it performs no function at all other than as a place holder for you to fill in the blanks. Basically it's saying "put the right information here"

Rappa
11-30-2005, 02:19 AM
Its like, a decoy link for a URL for yourself that dosn't point anywhere, Until you think of a necessary link or make a page for that link. Then you change it to a real URL.

Example:

Say im making a site and I decide to make a tutorials section but I didn't make the page yet. Most webmasters would do this

<a href="#">Tutorials</a> To show that there 'will be' a tutorials section, but it's not made or not up yet.

Unless you want to jump to a certain area in a page then you would use <a href="#TOP">Back to Top</a>

Would jump to where you set '#TOP' to.

Hope that helps a lil.

whizard
11-30-2005, 02:25 AM
Also, the pound (#) can be used in place of an actual address, if the link's purpose is not to load a new page, but to call some javascript or something, as below:


<a href="#" onclick="window.open('popup_file.html', 'popup_name',
config='height=xxx,width=xxx')">Click Here to open a popup window</a>


With this code, the main page would not go anywhere, but a new popup window would open when you clicked the link.

Dan

_Aerospace_Eng_
11-30-2005, 02:35 AM
Though it is good practice to put the link to the popup page there just incase the user has JS disabled by default (like me) then they would still see the link.

<a href="popup_file.html" onclick="window.open(this.href, 'popup_name','height=xxx,width=xxx');return false">Click Here to open a popup window</a>
The key to that is to use return false after the window.open function. If you don't want to put the # in your href to create a dead link, you should be able to just leave it blank, though I think in IE this might open windows explorer (that could be only locally).

whizard
11-30-2005, 03:06 AM
Wow, thats cool! Thanks!

Dan

grindy
11-30-2005, 03:10 AM
Wow !

Thank you all for the excellent explainations and assistance.

One thing that does still puzzle me though, is - if I use
<a href="#"
as a place holder, why doesn't that trigger an HTML code error ?
thx

_Aerospace_Eng_
11-30-2005, 03:12 AM
Because its not an error. You use a # to reference a name or id, if you just use the # the browser just loads the page looking for an anchor that refers to the # but since no name or id is set it just goes to the top of the page. Do you notice that the browser seems to reload the page if the # is pressed?

grindy
11-30-2005, 03:47 AM
Ahhh... I understand now..
Thank you all for the kind help. :)

harlequin2k5
11-30-2005, 10:32 PM
Though it is good practice to put the link to the popup page there just incase the user has JS disabled by default (like me) then they would still see the link.


I know I'm full of dumb questions, but please humor me...

Why does one turn off javascript?

gsnedders
11-30-2005, 10:36 PM
I know I'm full of dumb questions, but please humor me...

Why does one turn off javascript?

Adverts, popup windows, resizing the browser window, etc.

harlequin2k5
11-30-2005, 10:53 PM
told ya it was a dumb question :)

if one has their js turned off and a site has appropriate js (like a calendar or something like that) would that site then be lost to them or should the author have enough presence of mind to provide a non-js page?

I myself do not use javascript - I don't know the language and I haven't really found anything appropriate for any of my sites (with the exception of a floating menu that I used more for novelty than practicality)

_Aerospace_Eng_
12-01-2005, 12:02 AM
It just disables a lot of annoying things on pages sometimes like marquees, ads, etc. I use the noscript FF extension, it disables JS on page by default, I have the option to allow the pages to use javascript temporarily or permanently. Authors should make sure their page is functional with JS disabled. JS should not be required for a page to work.

rmedek
12-01-2005, 01:53 AM
Adverts, popup windows, resizing the browser window, etc.

Also… a lot of people tend to use other things to browse web pages besides the browser—I for one use my RSS reader to read most of my web sites nowadays—and those devices may not support javascript. The rule of thumb is, generally, if it's not a complete necessity, make sure it degrades gracefully. That goes for JS, Flash, CSS, etc. At least it should be a rule of thumb. :)

My two cents…

harlequin2k5
12-01-2005, 03:45 PM
My two cents…
That's worth a million to me :)

Like I said - I don't use it because it's not really something I want to learn but I thought it was important for me to ask that question as a continually budding web designer

Thanks for all the tidbits guys!



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum