0

I have a question about the way I should build my website. What if the user has javascript disabled, then all the client side programming will be disable.

Should I rely on php at first, and then just add the javascript/jquery/ajax just in case.

Also how could I make partial requests, so that one part of the page is posted back while the other part of the page doesnt refresh (for example, navigating through a list of products on the page through a pager , without the whole page refreshing, like a gridview). How to achieve that?

Sorry, if i was confusing

4 Answers 4

2

If your page requires JavaScript to work, then you will need to let the user know that he will need to turn on JavaScript to run your page, otherwise, if you want to support both users who have JavaScript disable and users who do not, you will need to do more work by making all changes done with JavaScript also be done on the server side.

Use AJAX to accomplish that whole changing content of page without refreshing.

Sign up to request clarification or add additional context in comments.

1 Comment

Think of jquery as a framework that has built in functions that make it easier to use javascript. So, YES, using the api.jquery.com/jQuery.ajax would work.
1

First question

The suggestion I have is to build the site under progressive enhancement.

The key function should be available to user who has javaScript turned off, this means you shouldn't depend on JS for HTML writing, CSS styling and form submission. Also you should always validate form submissions.

Second question

You could update part of your html with AJAX. To apply the first principle, You'd better make full post url for every anchor, this will fetch the page from server-side. When js is enabled, you could write AJAX call and diable the default anchor behavior to archive an AJAX page updates.

For example:

1.Provide <a href="specific_page.php"> on your html to ensure no-js user would access the url on your site.

2.When js is enabled, you could select the anchor and use the ajax request instead of the default anchor href.

$('a').click(function () {
  $.get('specific_ajax.php', //callback);
  return false; //cancel default redirect action
});

Further

You should know how to detect javascript disabled and use <noscript> as a fallback.

6 Comments

so basically, I need to create two copies of a file, if the user has javascript I should give him one way to use, and if he doesnt the other way..
Not really, you should build from the basic function in the beginning without JavaScript. Makesure the basic function is enabled for all the users. Then you could enhance your site with javaScript for effects/AJAX/animation etc. But the backbone must be usable for users.
hmm.. shouldnt I decide when and how to postback..because the central idea is whether to partially or fully postback, if I design the code with php only, I must do a full post back,.. cause many times I need to decide what to do. Posting this comment relies on ajax mainly. What about all asp.net controls, will they stop working if the user doesnt have ajax?
interesting update.. so do you mean providing <a href="#"> instead of <a href="specific_page.php"> ..hmm..I see this can be done with jquery..simply change the attribute href to # if it is enabled..does that what you mean?
hmm..I see, I could also do the same on the submit buttons in forms.. I see where you are going,,, thanks for the help
|
1

Use <noscript> tag to handle things when JS is disabled. Wrap your JS with test condition checking if JS is enabled. For partial page you could use iframe frame or ajax.

Typical use of <noscript>

<noscript>
      Your browser does not support JS, please <a href="some link">Update your 
browser or <a href="noScriptPage.html">go to</a> non JS page which may offer reduced functionality.  
</noscript>
<script>
  window.location("jsEnabledPage.html");
</script>

So if JS is working the user will be re-directed to the default page else he has options at his disposal.

3 Comments

And how would he test for JavaScript, if there's no JavaScript? It's like saying "All those who aren't here, raise their hand!".
lol..iframes..you are probably mad.. but if I use ajax and the user doesnt have javascript enabled,,then the whole site functionality is disabled, and I am screwed
@DmitryMakovetskiyd I object to your use of 'probably' in the above comment. ;)
1

It's been about ten years since any business has asked me to support browsers without js enabled. While it's certainly a valid need in some cases, I wouldn't bother with this sophistication unless you have been given specific instructions or have some insider knowledge of your niche user market (e.g. you are running a bank web site, building gmail, specialty mobile sites, etc).

In most other cases, a simple <noscript> noting that JavaScript is necessary to enjoy the site's full functionality will suffice.

You will generally want PHP/server-side-technologies to do as much of the work as possible. They will always win against client-side JavaScript for speed and performance. The exception, of course, is application development, where the page should exhibit responsiveness and avoid page reloads for simple content changes. That's where your ajax solutions would come in.

For your "partial requests" question, check out jQuery or another library which provides this functionality. They have excellent tutorials and tools to get you started.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.