user1003885
user1003885

Reputation: 41

Coding a website JavaScript disabled

I'm developing a website and want a status bar to stay anchored to the bottom of every page. The best way to do this seems to be using javascript. However, many browsers will have javascript disabled. So, wouldn't it be a best practice to not use javascript? I tested google with javascript disabled and their status bar doesn't even show up. That seems like a poor implementation. Is a web developer supposed to assume javascript should be enabled or is there a better best method for a standard?

Upvotes: 1

Views: 183

Answers (6)

user1003885
user1003885

Reputation: 41

Thanks for all the good advice. I was able to use CSS to achive my goal and eliminate javascript. At least it works in the few browsers that I tested it with. The emptyspace class creates a margin between the content and footer. Coding CSS is not fun in my opinion.

#emptyspace {
    float: left;
    width: 100%;
    height: 130px;
}

#footer {
    position: fixed;
    bottom: 0px;
    width: 100%;
    height: 125px;
    background: url(../images/grass-green-gradient.png);
    background-repeat: repeat-x;
}

Upvotes: 0

Wouter J
Wouter J

Reputation: 41934

JavaScript is almost on on every browser. I think 90% of you visiters don't even know you can switch it off. And the other 10% know why you shouldn't turn JavaScript off.

You can search for sticky footer or sticky header and you are getting much examples about how you can do something as this.

Upvotes: 0

T.J. Crowder
T.J. Crowder

Reputation: 1074475

Approxiately 2% of people worldwide are using browsers that don't have JavaScript, or they have it turned off. (Reference) So not a big number, but it's there.

This is where progressive enhancement is your friend. Try to create a status bar that does what you want (probably using position: fixed or position: absolute combined with some padding on your main content element) on most browsers, most of the time, without JavaScript. Then if you still think you need to use JavaScript for it to do exactly what you want, you can add that for the 98% of people who have it.

Upvotes: 4

Andrew
Andrew

Reputation: 13853

A sticky header should not need javascript anyway, you can do it just with position:fixed for example movethewebforward.org

Upvotes: 0

pimvdb
pimvdb

Reputation: 154848

It looks like you just want CSS, especially position: fixed; bottom: 0: http://jsfiddle.net/b6qwH/.

That way the element is anchored to the bottom of the screen, so also when scrolling.

Upvotes: 0

Jonathan Rich
Jonathan Rich

Reputation: 1738

Your site should still work for people who do not have JavaScript enabled, but it should work better for those that do have JavaScript enabled, and you should let users know that they aren't getting the best user experience because they don't have JavaScript enabled.

This is what Google, Facebook, and Yahoo do, and is the best way to reach the widest audience.

http://en.wikipedia.org/wiki/Progressive_enhancement

Upvotes: 0

Related Questions