
Solid, safe website tools.
Whatever your need, Will Bontrager builds powerful software solutions.
JavaScript Code, Tips3 Good Reasons to Publish Content with JavaScript Ajax Content From Other Domains Ajax has a built-in restriction allowing it to retrieve content only from its own domain. In other words, the domain where the web page is loaded into the browser is the only domain Ajax can retrieve content from. This article shows you how to get around that restriction. Altering Popup Window Behavior I've long avoided participating with "rate this" features at web sites because they required a page to reload after providing my vote. Same with surveys and other web page interactions. Answers To Questions About JavaScript Our primary focus at willmaster.com is CGI. However, we do receive some questions about JavaScript developed for Possibilities ezine articles and about JavaScript in general. A Printer-Friendly Web Page with Non-Printing Elements Here, I will give you a copy 'n paste example of how to let your site visitors print certain parts of a web page and exclude certains parts from printing. Automatically Inserting the Current URL Into Forms When you have the same form on many pages, and it needs to contain the current page's URL, then either the form needs to be edited for every page or an automated method is used to insert the current page's URL. Automatic New Window for External Links Pop one set of JavaScript code into your web page and all external links will open a new browser window for JavaScript-enabled browsers. Automatic Subscription Submission On Survey Results Page Now you can collect email address (and other information) in conjunction with a survey and automatically subscribe the email address to your ezine or autoresponder. Did you know you can switch background images like a slide show? It's not something I had previously thought about, until my imagination was stimulated at JavaScript Source Basic JavaScript Date and Time Functions Browser-Correct Download Instructions Something I've noticed since I started using non-IE browsers is that download instructions are provided, they're almost always specifically for the IE browser on Windows operating systems (right-click on the link then select "Save Target As..."). Cache-Independent Imported JavaScript Files Browser caching of content can be a problem if the content is subject to changing between page loads. Here, I describe a technique that works on every browser I've tested. And you don't need any cache-inhibiting meta tags. Change Form Field Values On The Fly with JavaScript This article will demonstrate how to automatically change a form field's value depending on which radio button is clicked. Changing Dropdown Content On-the-Fly (Without Reloading Web Page) You've seen web pages with two dropdown lists where making a selection in one causes the web page to reload. Once reloaded, the list in the other dropdown has changed. Changing Form Action URLs On-The-Fly Here's how to change the action="_____" URL on-the-fly, depending on which (if any) radio button is checked by the form user. Drop-down lists could be substituted for radio buttons. Changing Form Action URLs On-The-Fly (an Addendum) The reason an action URL with a query string rarely works is because a method="get" form, itself, generates a query string for the action URL. The result is a query string attached to the end of a query string. Controlling Checkboxes With JavaScript Sometimes it's desirable to control whether or not certain checkboxes are checked, or to do something depending on which ones are checked. Here is the source code of an Ajax engine you can use over and over, on many different web pages. With instructions how to use it. The focus is to make Ajax available even to those who have learned no programming skills. Copying Billing Form Fields Into Shipping Fields This technique is commonly used on professional order forms. It lets customers click something to automatically fill in shipping information without retyping identical information already provided in billing form fields. Or vice versa. Customer Friendly, Cart-less E-commerce Site Detecting a "Back" Button Click Certain events can be detected (page load, page unload, page re-focus) and, depending on which order they occur, determine with some certainty whether or not the "back" button was clicked. Determining Your Visitor's Time Zone Discover If a Browser Accepts Cookies Not all CGI programs, few in fact, check for double form submissions, those submissions that happen when a user clicks a form submit button more than once. Dynamic External JavaScript Files Dynamic external JavaScript generation, customizable with parameters used to access the web page. The article will explain it :) Dynamic Subordinate Dropdown Listbox You've probably seen examples of dropdown listboxes on a page where the content of one listbox is changed whenever a different selection is made in another listbox. This article and demonstration will show you how to do that -- without causing a web page reload whenever a new selection is made. Easy Mouseover Images For Your Site The concept is deceptively simple. Yet, the protection is as good as having hidden file names on the server. Effectively Requiring Cookies With All Browsers If you have any web pages that must not be viewed unless a certain cookie is set, this article contains the means to make it so. Electronic Content Syndication Methods When it comes to syndicating electronic content, two main syndication methods are employed: Delivering content directly to readers and Delivering content to publishers. Ensuring Two Form Fields Have Identical Information When two form fields must contain identical information before they can be submitted, this article shows you how to implement it. Mari and I were talking this morning and we came up with a Feeling Lucky button idea. Clicking on it redirects the browser to one in a list of our most popular web pages. Form "Required Fields" JavaScript Check Let your form user know, all at once and before sending the information to a script, about each required form field that hasn't been filed in (or checked, or selected). (1) Limit the number of characters that can be typed into a textarea field. (2) Give IE/Win users the ability to switch textarea word wrap on/off. This fortune cookie JavaScript generator can be used to deliver, as examples, a random fortune wish, discount amount, inspirational verse, coupon code, or link. Hide and Display Content On Demand You may have encountered web pages where an action on your part like clicking a link or checking a checkbox or moving the mouse over a certain part of the web page inserted causes additional content to appear on the page. The web site may have made it possible for another action to remove the content. When a mouse hovers over a link, the link URL is clearly visible in the browser's status bar. Sometimes that is not desirable. This article shows 2 ways to hide link URLs. How To Disable The Submit Button If you want to prevent multiple clicks on a form submit button, disable the button. How To Make an Image Roll Over with JavaScript You've seen images on web sites that putting your cursor over an image causes the image to roll over into another image. This article shows you a method that also tells the browser to preload the second image. Image Click Selects Dropdown Item Images can communicate quicker than words, and sometimes with better understanding. A picture of a tree is recognized instantly as being a tree, and is understood to be a tree whether the observer's native language is German, Spanish, English, or Space Alien. Image Map Triggered Image Rollovers This article presents a way to require that a site visitor views a certain web page and clicks on a certain link or button before the protected content is displayed in the browser. Inserting Affiliate Codes Into Links and Forms If you have your own affiliates, you may wish to insert affiliate codes into links and forms. Integrating with Payment Gateways Integrating software with payment gateways can be a confusing subject. It's a Cookie! Get Outta Here! When a page has performed it's purpose, a cookie can be set to redirect the browser to a different page on subsequent visits. JavaScript and CGI Talking to Each Other Sometimes it is desirable to publish information on a web page that can only be provided by a program running on the server. JavaScript Clocks and Calendars, Part I, Basic JavaScript Clock JavaScript Clocks and Calendars, Part II, Custom Date/Time Display Label Within The Form Field Handling Today I'll show you how to implement something that appears easy at first glance but can be a bit tricky. It is the label within the form field functionality seen in forms that must take up very little space on a web page. Loading Two or More Frames Simultaneously Logging Syndicated Content Page Loads Today, I'll show how and provide the means to do your own logging of content you syndicate to other web sites. When certain form fields must be required, here is a method using JavaScript. This can be implemented whether or not the form handling program also does error checking. Making Your Own Layered Sub-Menus This article shows you how to code a sub-menu system that layers a box with menu-items onto the current web page, over the page's normal content. You've seen images swapped when the cursor moves over a link or the image itself. Today, I'll show you how to do a DIV swap. The DIVs being swapped can contain anything DIVs can contain -- images, text, forms, whatever. The article contains a complete example. Code is included to copy 'n paste into your web page to see it work. Multi-Page Forms with JavaScript and Cookies If your form processing software does not have multi-page form capability, this article shows you how to carry the information from one form page to another using JavaScript and cookies. When folks fill out your forms, sometimes they type their name in all lowercase letters. And sometimes they type them all caps. Names are personal. Correct capitalization might be a little thing. But it can mean a lot. The JavaScript accompanying this article will adjust capitalization of names. Let's suppose you want to provide your site visitors the option of automatically causing a new browser window to open whenever they click on a link -- by simply checking one checkbox. If you put the checkbox on more than one page, and you want to pre-check the box if the visitor checked it on a previous page, this article shows you how to do that, too. Put "New" markers next to links that you have added or changed since your visitor last viewed your web page with this JavaScript/cookie system. One-Click Content Reveal and Image Swap Wonderful things can be done with JavaScript and CSS. Today, you will learn how to reveal a block of content and swap an image with one click. An event is something that happens. In the context of this article, events happen on a web page. The event can be anything at all, from displaying a popup to logging the visitor to playing a tune. Popup Form Knows URL and Title of Parent Window Whether the JavaScript you use launches a popup window or a normal browser window doesn't matter, the URL and title of the parent window is available. Nor does it matter how the JavaScript is written that launches the window -- it can be JavaScript embedded in a link or through a function. Popups Fill Form Fields in Regular Window With complex forms, it may seem less daunting to the user when parts of it are hidden or sectioned off in a popup. Pre-Fill and Multi-Page Forms with JavaScript When information is passed in a URL parameter to a web page, JavaScript in the web page can pre-fill form fields. Presenting a "Good-bye" Message Without Popups The proliferation of popup blockers and ad removal software has eroded those income producing methods for many web site publishers. And it's only getting worse. Pro.Rate(TM) has a near instant feedback mechanism. It allows site visitors to rate an idea or story or product with minimum interruption. Putting Form Confirmation Pages Into Popups Random and Duplicate Content With JavaScript We receive numerous questions about random content delivery. These are usually related to ads, images, or other content that appears on web pages next to the main copy. JavaScript can be used for this job. A generator is available to create the Javascript. Relatively Simple Form Spam Prevention Form spam happens when a robot or other remote software automatically fills in the fields of your form and submits it. JavaScript is used to detect whether or not the form user is human. If a click in a form field is detected, human is assumed. Otherwise, the form user is assumed to be software. Reliable "JavaScript-Required" for Forms There may be times when a certain form may not be used at all except by browsers with JavaScript enabled. The answer is to use JavaScript to publish the submit button. With no JavaScript, there will be no submit button. If you work with JavaScript code sometimes, I've got a present for you. It is a function you can use to replace certain areas of a web page with alternate content. The function is copy 'n paste; no modifications necessary. Once in a while we receive reports from web site owners that a visitor had to re-fill in all fields after submitting a form and then clicking the "back" button to correct information. All the fields go blank. Today's JavaScript is designed to take care of that problem. Running Many With One cron Command It is possible to run many scripts -- CGI, PHP scripts, anything with an http://... URL that can be loaded into a web browser window -- on one or more domains with one cron command. Does your sales page print cost/profit ratios or other numbers to show prospective customer how much they could gain from purchase of your product or service? Here is a calculator allowing prospective customers to estimate number of sales and/or other factors. At a special web page, type a certain sequence of characters on your keyboard. If you get it right, you are redirected to the real secret web page. An interesting question arrived in my email box a few days ago. The sender is running an affiliate program that uses cookies to determine which affiliates are credited with sales. The question was how to use Master Form V3 to send an email containing the affiliate cookie. Setting and Reading Cookies with JavaScript The intent of this article is to make setting and reading cookies with JavaScript an easy thing for you to do. Site-wide JavaScript Implementation Specifying Iframed Page Display Area When a web page is displayed in an HTML iframe tag, the upper-left part of the page displays in the iframe content area. Submit Button Multiple Click Trapper Looking back, I notice that every three years I write about another method of providing instant information. The latest is about the Stock Ticker Box. Things To Do With Textarea Form Fields Getting form input, presenting text for copying, varying text size and color, automatically selecting content with a click, changing background colors, using background images, all these are addressed in this article. Tooltip flyovers used judiciously can provide help at the very moment it's needed. Supplementary information can be provided for images, form field labels, or certain blocks of text, as examples. The information can be professionally and elegantly presented. Track which features prompt feedback from your web site visitors. A link on a web page that leads to a contact (or other) form can cause a tracking code to be included in the email sent to you. Validating Credit Card Numbers On-The-Fly Images can communicate quicker than words, and sometimes with better understanding. A picture of a tree is recognized instantly as being a tree, and is understood to be a tree whether the observer's native language is German, Spanish, English, or Space Alien. Your Form Knows URL Of Previous Page You have a web page with a recommend form or a form to request more information. You have links to the form at various web pages. And you want the form to know which web page the user came from. This article shows you how to give the form the URL of the web page where the link was clicked. |
|
|
© 1998-2001 William and Mari Bontrager |
|