Software, your way.
How To Get Good Custom Software
(Download)
(PDF)
burger menu icon
WillMaster

Will Bontrager Blogs Website Techniques

WillMasterBlog > Site Maintenance

Website Link Checking (Desktop Software)

Website link checking is necessary. Dead links can make a website seem old and unmaintained. I've heard that many dead links can have an adverse effect on search engine rankings, although I do not know with certainty whether that is true (I'm not an SEO expert).

Fortunately, there is software to automate link checking. It is available both online and as apps for running from a desktop computer.

A big downside to using online services, whether free or paid, is that a person is dependent on the website remaining online and current. While it's there and usable, it can be handy to have. When it goes away, a person needs to find a different website to provide the service or go without.

This article is only about desktop apps.

Downloading apps and using them from a desktop computer can also have downsides. Downsides include overloaded computers that are already running slow. Downsides also include software that eventually needs updating but might no longer be maintained.

While I was using a Windows desktop, I used Xeno's Link Sleuth for links checking. But that was much over a decade ago. (I now use a Mac desktop.) Just now, I checked and the Xeno software is still downloadable and still free. It might or might not work on the Windows version you are running. Check the specifications.

The Screaming Frog software is a link-checking option for both Windows and Mac desktops. You'll find a "download" link at the pricing page. The software does much more than just check links. Its primary purpose is to help with SEO. It is free to use up to 500 links. After that, there is a fee.

Currently, what I use mostly is the Integrity links checker for Mac. The free version has no URLs limit. If you want to use the software for more than just checking links, you'll see a chart of features and prices at that page. There is no Windows version of Integrity.

One of the above software titles might be appropriate for you to install on your desktop computer — assuming you want to use desktop links checking software.

With my experience maintaining websites, I learned it is important to check websites for broken links either on an intermittent or regular basis. No more than a few weeks should transpire between checks.

(This content first appeared in Possibilities newsletter.)


WillMasterBlog > JavaScript

Dynamic Year List Dropdown

Form dropdown fields with year selections related to the current year need to be updated at the start of every year. That is, unless you have the dropdown set up to automatically stay current, which is what this article is about.

An example of selections related to the current year are credit card information forms, where you may want the current year and the next 6 years available for selection. Another example is a form to select the year for a calendar download, in which case the next year and some years thereafter should be selectable.

The first of the following examples lists the current year and next year. The second lists five year numbers, beginning with next year. The third lists the 8 previous years.





The above dropdown selection examples are created with this JavaScript. Following the code are instructions.

<select>
<option value="">-- Select Year --</option>
<script type="text/javascript">
var StartYear = +0; // use +0 to start with the current year; -1 for last year; +1 for next year; +3 for three years from now; or so forth.
var HowManyYears = 2; // How many years to list in the selection.
var today = new Date();
var year = today.getFullYear();
for(var i=0; i<HowManyYears; i++)
{
   var y = (year+StartYear)+i;
   document.write('<option value="' + y + '">' + y + '</option>');
}
</script>
</select>

The first 2 lines and the last line of the above code represent your selection form field:

  • (line 1) your select tag.
  • (line 2) the optional first selection for instructions.
  • (last line) the closing </select> tag.

Your select tag might have an id attribute and/or a name attribute. It might also have other attributes.

In between the code that represents your selection form field is the JavaScript that writes the options with the year numbers. The JavaScript has two places to edit:

  1. Update the +0 value in the var StartYear = +0; line.

    To start the dropdown list with the current year, specify +0 as the value.

    To start the list with last year, specify -1 as the value or to start the list with next year, specify +1.

    The digit you use represents the number of years. The "+" or "−" represents the next or past, respectively. As an example, +3 starts the dropdown list with the year number for 3 years in the future.

  2. Update the 2 value in the var HowManyYears = 2; line.

    The number that 2 is replaced with tells the JavaScript how many year numbers to populate the dropdown with. (Year numbers will be sequential, ascending.)

The JavaScript automatically lists the year numbers in the dropdown in relation to the current year. It gives you a year list.

(This content first appeared in Possibilities newsletter.)


WillMasterBlog > Content Protection

How To Prevent Web Page Printing

Generally, when a browser's menu is used to print a web page, the web page prints. Even if the site owner wouldn't want it to print.

Various browsers have various ways to cause a web page to print. The "File" menu item of browsers running on desktops/laptops often has a "Print..." selection available. Control-p or Command-p may be used with some browsers. For devices, you may find a print menu item under "share" or "page" options. Every browser I've observed with this in mind had some way to print the web page.

Perhaps the web page contains a temporary link to a download. Or the person's test scores. Perhaps secret rules of a game, or a hint for the next move. Those are examples of web pages a person might want to prevent printing.

One line of CSS can be used to do the trick.

@media print { * { display:none; } }

With that CSS effective, attempting to print the web page from the browser will print a blank sheet of paper.

A caveat is that someone determined to print the page could do a screenshot and then print the screenshot image. Folks less determined or less technically oriented will be stymied.

Expanded information on this subject:

To prevent a web page being printed, use the one line of CSS near the beginning of this article and the browser will be prevented from sending the web page data to the printer for printing.

Attempts to print the web page will yield only blank pages.

(This content first appeared in Possibilities newsletter.)


WillMasterBlog > Tips and Tricks

Multiple Launches With One Cron Schedule

When you have several scripts that need to run at a specific frequency — a daily run of a script to compile stats from a log file is one example — setting up one cron instead of many may save time and frustration.

What you do is install the script below. In a separate file, list the URLs of the scripts that shall be run. Set up cron to run the script every day (or other schedule). When the script below runs, it does an HTTP request to each URL in your list, one URL at a time.

Unlike cron, this system lets you run scripts at any public URL at any domain, whatever PHP or other scripts that a browser or bot can access. Cron requires scripts to be available on the same server where cron is set up.

Most hosting companies provide a dashboard method for you to set up cron for your script. If your hosting company does not, articles Cron and Using Cron have information you may be able to use (warning, highly technical).

Here is the source code. One customization is required, talked about further below.

<?php
/*
Run All URLs
Version 1.0
March 17, 2024
Will Bontrager Software LLC
https://www.willmaster.com/
*/

// Specify the location of the file with the URLs to run.
$FileWithURLs = 'subdirectory/urls2run.txt';
// End of customizations.

$listOfURLs = array();
if( file_exists($FileWithURLs) ) { $listOfURLs = file($FileWithURLs); }
else { echo "File $FileWithURLs not found."; }
foreach( $listOfURLs as $url)
{
   $url=trim($url);
   if( preg_match('!^https?://!i',$url) )
      { file_get_contents($url); }
}
echo 'OK';
?>

Customization —

The above script will look for a text file (see next paragraph) that contains URLs to run. The text file can be anywhere on the server that could contain web pages.

When you have decided where to put the text file and what to name it, then replace subdirectory/urls2run.txt with the file's location. The file is not required to have a .txt file name extension; it can have any extension you wish to give it or even no extension at all. In other words, it needs to be a text file but you can give it any file name you wish to give it.

Upload the above source code as script runURLs.php or other *.php file name. Make a note of its URL.

Put the URLs of scripts you want to run into the text file specified in runURLs.php (see further above). URLs in the text file should be one URL per line. Script runURLs.php will ignore any lines that do not begin with http:// or https://.

Note: Do not specify the URL of runURLs.php in the text file containing URLs to run. You would end up with an infinite loop.

Set up a cron schedule for runURLs.php. Whenever runURLs.php runs, it will run the URLs in your text file as HTTP requests.

This system can put any URL on the internet on a scheduled run. URLs can be added and removed by updating the text file.

(This content first appeared in Possibilities newsletter.)


How Can We Help You? balloons
How Can We Help You?
bullet Custom Programming
bullet Ready-Made Software
bullet Technical Support
bullet Possibilities Newsletter
bullet Website "How-To" Info
bullet Useful Information List

© 1998-2001 William and Mari Bontrager
© 2001-2011 Bontrager Connection, LLC
© 2011-2024 Will Bontrager Software LLC