Friday November 13, 2009
JavaScript can add complex HTML to a web page
A new addition to my library of scripts that you can use on your own site is my new Form object script which provides you with an object that has simple to use methods to create a form with all the form field types you are most likely to want to use (it doesn't handle file inputs or optgroups but most of the time you will not need those). The object uses standard DOM calls to add the form into your web page as well as providing plenty of ways to reference the fields from your stylesheet in order to format it the way you want.
Dynamic Forms
Thursday November 12, 2009
Web pages are open source and there is nothing you can do to protect the content
Every so often I receive emails about my
Image Protection JavaScript that places the image in the background of a table with a transparent image in front of it. All of these emails have pointed out that there are other ways to obtain the image and that it is not really protected. In fact there is
no way to stop people obtaining the content of your web page since they have it already on their computer when they view your page. The same is true even if you use JavaScript to
encrypt your page source since your visitors all have something that can decrypt it for them (called a web browser). In fact applying something as simple as a
no right click script (which is the least effective way to try to protect anything) will just drive visitors away from your site. Any of these techniques may stop newbie web users from taking your code and images (and will do so at least as effectively as much longer codes and more expensive solutions found elsewhere on the web) but nothing will prevent someone who knows how the web works from obtaining whatever they want from your site.
Wednesday November 11, 2009
How far apart are specific characters? Find out with JavaScript
Continuing with our look at validating text input fields using JavaScript, the tenth tutorial in the form validation series looks at how we can test to make sure that selected characters in the input are a certain distance apart.
Minimum and Maximum Distance
Tuesday November 10, 2009
JavaScript can add to the page when a feature is supported and not add when it isn't.
Having an "Add to Favourites" link is popular with people just starting out writing web pages. Not all browsers support such a link though and some pople have written scripts that use the wrong way of testing if the browser does support it. This version of the "Add to Favourites" script not only uses the correct method of testing if the browser supports the link, it supplies the necessary code for all the browsers that do provide a way to support such a link, and just leaves an empty tag in the page where the link would have gone if the browser doesn't support it.
Unobtrusive Add to Favourites