...

View Full Version : Work Around for JavaScript disabled browsers?



Dabooj
08-07-2008, 10:10 PM
Hi Guys,

I am a newbie to this forum so please forgive me if i make any silly mistakes & feel free to correct me.

Now, i have been using JavaScripts within HTML files for quite a long time now. It has always been essential for the work i have done with web development.
I work on basic web developments but i always try to hard code everything myself so that i get a better understanding of what i do.

the problem is that i have a website that uses javascripts extensively but if someone views this without javascript ebabled on their browsers then the layout will fall apart & the funtionality won't work.

My main concern is that i have buttons which show/hide DIV elements as pages (i.e. click on home then the home div is displayed & all others divs are hidden, click on 'Contact Us' then this div becomes viewable & all others are hidden, etc).
I have a simple javascript funtion which accepts the div number & shows this div & the FOR loop goes through the remaining DIVS & hides them.
If JS is disbled then this won't work.

Is there a way around this issue?
Or is there a simple way of re-programming my web site to work in a different way?

Any help would be really appreciated.

Thanks,

Shuja

ninnypants
08-08-2008, 12:06 AM
nope that isn't possible. The general rule is that you shouldn't rely on scripting for the functionality of your pages scripting should just enhance the users experience.

oesxyl
08-08-2008, 12:19 AM
Or is there a simple way of re-programming my web site to work in a different way?
probably there is not simple:
- make the site to work only with html at least at a minimal level
- use css for presentation without javascript
- add javascript to add rich functionality

http://onlinetools.org/articles/unobtrusivejavascript/index.html

regards

barkermn01
08-08-2008, 12:55 PM
Dont use divs like that do you know how long a site would take to download if itis all in the one file
it might be ok if there was a site with out any images but what site is that if some one with a modem or EDGE tryed connecting the site it would take a life time

abduraooft
08-08-2008, 03:13 PM
Instead of applying display:none; directly to the divs by default, create a CSS like

div.hide{
display:none;
} and then apply this class to your required divs in the load event of page, like


window.onload=function(){
var divs=/* get the required divs*/;
/*loop through each div and set the above defined class to the*/
//div[i].className='hide';
}. Thus, if there is no javascript, user can see all the divs.

VIPStephan
08-08-2008, 03:23 PM
OK, oesxyl has covered it pretty precisely already but I’d like to add the all-encompassing term that’s used for that practice, and which may help understand the concept: Progressive Enhancement (http://en.wikipedia.org/wiki/Progressive_Enhancement). That’s the only way you should go in modern web development.

Dabooj
08-09-2008, 01:11 PM
Ok, Thank you all for the helpful tips.
The idea of allowing the DIVS to appear without the javascript code enabled is a no-go.
The divs i have created replicate a distinct individual page (e.g. DIV1=Home page, DIV2=Services page, div3=contact us, etc).
So displaying all the data (in divs) one after the other would not work in this case.

So, i've decided to drop using the DIVS & use something else to act as a page load within the main web page.
So my question is which is best to use? Frames, inline frames (my prefered choice at thsi moment) or should i simply have FULL seperate HTML pages for each section?
The seperate HTML will have to contain all the menus & images in each page which i assume would be a bad idea but which one do you guys recommend?

Or is there a better way of having pages or sections appearing in a web page?

Regards,

Shuja

Bill Posters
08-09-2008, 02:35 PM
window.onload=function(){
var divs=/* get the required divs*/;
/*loop through each div and set the above defined class to the*/
//div[i].className='hide';
}. Thus, if there is no javascript, user can see all the divs.

You should check for the presence of an existing className first, as you may end up overwriting them, using the script approach above.

e.g.

div[i].className += (div[i].className == '') ? 'hide' : ' hide';

…fwiw™.

Bill Posters
08-09-2008, 03:07 PM
…or should i simply have FULL seperate HTML pages for each section?
That's a reasonable starting place.


The seperate HTML will have to contain all the menus & images in each page which i assume would be a bad idea?
not a bad idea at all. It's the standard approach for all non i/frames-based pages on the web.

Or is there a better way of having pages or sections appearing in a web page?[/QUOTE]
An approach worth considering is to have a single 'parent' page and use includes (http://www.tizag.com/phpT/include.php) to bring in the relevant content sections - based on parameters in the url.

e.g.


www.yourdomain.com/index.php?section=home

The pages are still self-contained and complete and the whole page reloads each time, but by making it 'modular', you can make the whole thing more easy to maintain and update. You're effectively reloading the index document, but with

If your host server supports PHP (or equiv) then take a look at switching to an includes-based approach.


If you still wish to have the immediacy of instant content switching, then you could overlay some AJAX to pull in the relevant section headings and content.

http://www.google.com/search?q=hijax

Be aware, though, that using AJAX can have a negative impact on certain aspects of usability, such as bookmarking and the back button.

Incidentally, try to avoid i/frames as well, as they too have usability issues, such as bookmarkability and linkability, which impacts on how users arriving from search engines might be able to use the website.

Dabooj
08-09-2008, 07:24 PM
Ok, the PHP options seems to be the suggestion from you guys & i'm happy to go with this BUT i am a novice at HTML coding & i am even more of a novice (lets saying complete beginner) at PHP.
So much so that i don't know whats needed to install it. Can anyone help?

Regards,

Shuja

Bill Posters
08-09-2008, 08:03 PM
Ok, the PHP options seems to be the suggestion from you guys & i'm happy to go with this BUT i am a novice at HTML coding & i am even more of a novice (lets saying complete beginner) at PHP.
So much so that i don't know whats needed to install it. Can anyone help?

Chances are, your host server may already have it installed.

It's easy to checků
e.g. http://www.phpinclude.net/php101.php?T=1

It's great to install it locally, to enable you to develop locally and launch when finalised, but for the most part, you can get by perfectly well by developing online, using your host space.

barkermn01
08-10-2008, 04:23 PM
you could have all the Divs disabled and a none div version of the site and the divs open ontop then get javascript onload to show the div that way if Javascript is disabled they still get the site and if it is enabled that get the div version

But just for the Record i still think its a no go verry slow site



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum