Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 111399
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 11, 20262026-05-11T02:22:44+00:00 2026-05-11T02:22:44+00:00

I’ve tried my best to be a purist with my usage of Javascript/Ajax techniques,

  • 0

I’ve tried my best to be a purist with my usage of Javascript/Ajax techniques, ensuring that all Ajax-y behavior is an enhancement of base functionality, while the site is also fully functional when Javascript is disabled. However, this causes some problems.

In some cases, a DOM node should only be visible when Javascript is enabled in the browser. In other cases, it should only be visible when disabled. Take for instance a submit button on a form that has a drop down with an onchange handler that auto-submits (using JQuery’s form plugin):

<form method='post' action='.'>     <label for='id_state'>State:</label>     <select name='state' id='id_state' onchange='$(this.form).ajaxSubmit(ajax_submit_handler);'>         <option value='AL'>Alabama</option>         <option value='AK'>Alaska</option>     </select>     <input class='with_js_disabled' type='submit' value='OK' /> </form> 

and the Javascript:

<script type='text/javascript'>     $(document).ready(function()     {         $('.with_js_disabled').hide();     }); </script> 

When Javascript is enabled, the submit button is not required (due to the onchange handler). However, JQuery’s $(document).ready function (and the more direct document.onload) is only called after the page has been fully loaded and rendered – hence, the submit button is initially displayed and a ‘flash’ occurs when the Javascript is executed and the node’s display is set to ‘none’.

I’ve accepted this as the cost of doing business, and haven’t found a way around it. But is there a technique I’m not aware of that will minimize the effect, or even outright eliminate it?

EDIT:

The <noscript> solution mentioned by many people below seems promising, but isn’t working for me on Safari. However Prestaul’s 2nd suggestion works beautifully:

<body>     <script type='text/javascript'>         document.body.className += ' has_js';     </script>     <!-- the rest of your page --> </body> 

This can then be styled using straight CSS:

body .js_enabled_only { display: none; } body .js_disabled_only { display: block; } body.has_js .js_enabled_only { display: block; } body.has_js .js_disabled_only { display: none; } 

This second line is just for reference and can (and should) be removed to avoid circumstances where your element shouldn’t be display:block. Likewise, you may need different variations on the third line for other display styles. But this solution is nice and clean, IMO, and in my tests entirely eliminates the flicker effect.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. 2026-05-11T02:22:45+00:00Added an answer on May 11, 2026 at 2:22 am

    How about combining some of these solutions:

    <style type='text/javascript'>     .only-without-script {         display: none;     } </style> <noscript>     <style type='text/javascript'>         .only-with-script {             display: none;         }         .only-without-script {             display: block;         }     </style> </noscript> 

    or I prefer adding a class to the body (place your <script> tag at the top of the body and don’t use the .ready event):

    <head>     <style type='text/javascript'>         body.has-script .something-not-ajaxy {             display: none;         }          input.ajaxy-submit {             display: none;         }         body.has-script input.ajaxy-submit {             display: inline;         }     </style> </head> <body>     <script type='text/javascript'>         document.body.className += ' has-script';     </script>     <!-- the rest of your page --> </body> 
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
I have just tried to save a simple *.rtf file with some websites and
link Im having trouble converting the html entites into html characters, (&# 8217;) i
That's pretty much it. I'm using Nokogiri to scrape a web page what has
I used javascript for loading a picture on my website depending on which small
I've got a string that has curly quotes in it. I'd like to replace
I am reading a book about Javascript and jQuery and using one of the
I am doing a simple coin flipping experiment for class that involves flipping a
I have a French site that I want to parse, but am running into

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.