AJAX

Users without JavaScript and what to do about them

Here is what I do:

<noscript>
	<div style="color:#FF0000">
   	<strong>Sorry!</strong><br /><br />
      Please enable JavaScript on your browser to be able to use advanced features of this site.
      <br /><br /><br />
      <strong>Internet Explorer 6 or 7</strong>
      <ul style="list-style-type: decimal">
      	<li>Click the Tools menu.</li>
         <li>Select Internet Options.</li>
         <li>Click the Security tab.</li>
         <li>Click the Custom Level button.</li>
         <li>Scroll down until you see the 'Scripting' section. Select the 'Enable' radio button for 'Active Scripting.'</li>
         <li>Click the OK button.</li>
         <li>Click the Yes button in the confirmation window.</li>
      </ul><br />
      <strong>Firefox 2 or 3</strong>
      <ul style="list-style-type: decimal">
      	<li>Click the Tools menu.</li>
         <li>Select Options.</li>
         <li>Click the Contents tab.</li>
         <li>Select the 'Enable JavaScript' checkbox.</li>
         <li>Click the OK button.</li>
      </ul><br />
      <strong>Safari 2 or 3</strong>
      <ul style="list-style-type: decimal">
      	<li>Click the Safari menu.</li>
         <li>Select Preferences.</li>
         <li>Click the Security tab.</li>
         <li>Select the 'Enable JavaScript' checkbox.</li>
      </ul>
   </div>
</noscript>

“noscript” tag ensures that users without JavaScript will see this message ;)

Archived under AJAX, JavaScript, Web Development Comments

jEditable and password input type support

I wrote a post earlier about how jEditable (a jQuery) plugin needed password support and the author of the plugin wrote back and said here is how to add this feature:

$.editable.addInputType(’password’, {});

You can read more here:
http://www.appelsiini.net/2007/8/custom-input-types
http://www.appelsiini.net/2008/4/autogrow-textarea-for-jeditable

This plugin is really great and we are doing some exciting things on Bloggapedia with it.
We will launch early this week hopefully because we are working on a recommendation engine.

Happy Coding :)

Archived under AJAX, JavaScript, Projects, Web Development Comments

Password Support for Jeditable, a Cool jQuery Plugin

Here is the original plugin:
http://www.appelsiini.net/projects/jeditable

It let’s you implement inline editing capabilities and it’s supported by major browser.
Here are some examples:
http://www.appelsiini.net/projects/jeditable/default.html

An example usage is like this:

$(".edit_area").editable("http://www.example.com/save.php", { 
         type      : 'textarea',
         cancel    : 'Cancel',
         submit    : 'OK',
         indicator : "<img src='img/indicator.gif'>",
         tooltip   : 'Click to edit...'
     });

The problem is, it doesn’t support password input types, but here is how to add this support.

1 - Open the plugin file.
2 - Find this code:

text: { 
	element:function(settings,original) {
		var input=$('<input>');
		if(settings.width!='none') {
			input.width(settings.width);
		}
		if(settings.height!='none') {
			input.height(settings.height);
		}
		input.attr('autocomplete','off');
		$(this).append(input);
		return(input);
	}
},

3 - Add this after that:

password: { element:function(settings,original) {
		var input=$('<input type="password">');
		if(settings.width!='none') {
			input.width(settings.width);
		}
		if(settings.height!='none') {
			input.height(settings.height);
		}
		input.attr('autocomplete','off');
		$(this).append(input);
		return(input);
	}
},

Now you can do:

$(".edit_area").editable("http://www.example.com/save.php", { 
         type      : 'password',
         cancel    : 'Cancel',
         submit    : 'OK',
         indicator : "<img src='img/indicator.gif'>",
         tooltip   : 'Click to edit...'
     });

It’s odd that the developers didn’t add this capability…

Archived under AJAX, JavaScript, Web Development Comments (3)

How to force the browser to renew a cached image with JavaScript

Yes, you can do it with JavaScript, it’s simple; assume that the name of your image 2.png and you are writing it dynamically to a web page the only thing you need to do is this:

var image = 'http://www.example.org/2.png?' + new Date().getTime();

To the browser, this is a new URL so it will download the image again but to the web server this is the same image regardless of what’s after the question mark.

Obviously you can adapt this to your own needs…

Archived under AJAX, JavaScript, Web Development Comments

Should we stop supporting users without JavaScript?

I say YES!

I’m doing it from now on, just like Facebook and many others, I will show them a message:
Sorry, you won’t be able to use this site until you enable JavaScript on your browser.

I think it’s time for AJAX everywhere and web applications should start being modern and interactive…

Archived under AJAX, JavaScript, PHP, Web Development Comments (5)