Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 12 of 12
  1. #1
    New to the CF scene
    Join Date
    Aug 2008
    Posts
    6
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Exclamation Work Around for JavaScript disabled browsers?

    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

  • #2
    Regular Coder ninnypants's Avatar
    Join Date
    Apr 2008
    Location
    Utah
    Posts
    504
    Thanks
    10
    Thanked 47 Times in 47 Posts
    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.

  • #3
    Master Coder
    Join Date
    Dec 2007
    Posts
    6,682
    Thanks
    436
    Thanked 890 Times in 879 Posts
    Quote Originally Posted by Dabooj View Post
    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/unob...ipt/index.html

    regards

  • #4
    Regular Coder
    Join Date
    Nov 2007
    Location
    Leeds, UK
    Posts
    514
    Thanks
    24
    Thanked 19 Times in 19 Posts
    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

  • #5
    Supreme Master coder! abduraooft's Avatar
    Join Date
    Mar 2007
    Location
    N/A
    Posts
    14,865
    Thanks
    160
    Thanked 2,224 Times in 2,211 Posts
    Instead of applying display:none; directly to the divs by default, create a CSS like
    Code:
    div.hide{
    display:none;
    }
    and then apply this class to your required divs in the load event of page, like

    Code:
    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.
    The Dream is not what you see in sleep; Dream is the thing which doesn't let you sleep. --(Dr. APJ. Abdul Kalam)

  • #6
    The fat guy next door VIPStephan's Avatar
    Join Date
    Jan 2006
    Location
    Halle (Saale), Germany
    Posts
    8,928
    Thanks
    6
    Thanked 1,041 Times in 1,014 Posts
    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. That’s the only way you should go in modern web development.

  • #7
    New to the CF scene
    Join Date
    Aug 2008
    Posts
    6
    Thanks
    0
    Thanked 0 Times in 0 Posts
    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

  • #8
    Senior Coder
    Join Date
    Feb 2003
    Posts
    1,665
    Thanks
    0
    Thanked 27 Times in 25 Posts
    Quote Originally Posted by abduraooft View Post
    Code:
    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.
    Code:
    div[i].className += (div[i].className == '') ? 'hide' : ' hide';
    …fwiw™.

  • #9
    Senior Coder
    Join Date
    Feb 2003
    Posts
    1,665
    Thanks
    0
    Thanked 27 Times in 25 Posts
    Quote Originally Posted by Dabooj View Post
    …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 to bring in the relevant content sections - based on parameters in the url.

    e.g.

    Code:
    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.

  • #10
    New to the CF scene
    Join Date
    Aug 2008
    Posts
    6
    Thanks
    0
    Thanked 0 Times in 0 Posts
    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

  • #11
    Senior Coder
    Join Date
    Feb 2003
    Posts
    1,665
    Thanks
    0
    Thanked 27 Times in 25 Posts
    Quote Originally Posted by Dabooj View Post
    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.

  • #12
    Regular Coder
    Join Date
    Nov 2007
    Location
    Leeds, UK
    Posts
    514
    Thanks
    24
    Thanked 19 Times in 19 Posts
    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


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •