EW Resource

JavaScript Tips


Creating accessible JavaScript pop-up windows

The usual script for creating pop-up windows does not a) work with JavaScript turned off and b) does not meet accessibility requirements. This method meets both of these requirements and is what I used, with a few enhancements, in the PopWin EW Add-In


A neat way to open images over the main page. Some Ajax sites use a similar technique.  Lightbox

Ajatix have an EW Add-In (all versions) that makes using the lightbox effect a cinch.

Forcing a download for files

If you have downloadable files on your site, doc, xls or pdf for example, you may wish to force the users to download the files rather than open them. This requires some complex script in asp or php but a simple bit of JavaScript can at least prompt users to download and force them to take the decision, rather than have files open automatically.

Try this document link

Copy the code below and paste into your Code view in EW, then amend as needed.

Showing / Hiding text when a link is clicked

It's sometimes useful to hide text on a page and only show it when a user clicks a relevant link. On a Frequently Asked Questions (FAQ) page for example. Try the following links. Click to show, click to hide again.

What is Expression Web?

Expression Web is Microsoft's professional web design tool

Where is the home page for the Expression family?

The Expression family home page is here


Use the Show-Hide V4 Add-In.

My site won't validate. The JavaScript gives errors.  

A simple thing that often catches you out when you first validate a page on the W3C site. (Use the browser toolbars to give easy access to this).

The solution is to comment out the JavaScript as you might have done in the past for old browsers. Eg:

<script type="text/javascript">



Once this is done the page will valid normally without errors from the JavaScript

Compress your JavaScript files to minimise page download time

It very easy to end up with a JavaScript file of several kilobytes and compressing it can reduce the size significantly. There are several compression tolls available on-line and one of the best is JS Minifier