Category: Javascript

Changing the window scope in Firebug

If I had to choose one piece of advice for new web developers, I’d tell them to learn to use Firebug. Firebug is probably the most valuable debugging tool available, but if you are just getting started, it may seem pretty opaque at first.

In addition, some things do not appear to work as advertised. In particular, the “cd” function does nothing as far as I can tell.

The page that documents the commands you can use within Firebug lists the cd command as a way of changing the window scope:

Picture 23.png

Continue reading

A SCORM-ready template: Part 2A. Add Flash Video to your learning module

What files are required to add video to your learning module?

The player we are using for embedding streaming media into the SCORM template. is the Jeroen Wigering media player. Some of the necessary files are already included in the template and do not need to be touched:

  1. includes/mediaPlayer.swf (already included in template)
    this file generates the player according to the settings you include in the content page.
    mediaPlayer
  2. js/swfObject.js (see for more info on swfObject
    this file contains the code necessary to avoid the ActiveX problem with embedded SWFs in Internet Explorer, and generates embed code used by other browsers. A reference to this file already exists in the head of each module page, so you do not need to include it again.
    swfObject
Continue reading

Getting the WYSIWYG module to work in Drupal 6

I had a lot of trouble getting TinyMCE text editor to work consistently in Drupal 5.9, so when I installed Drupal 6 and was scanning through the available modules, I was very glad to see that the WYSIWYG editor module could function as a replacement.

wysiwygEntire.png

Although the easy-to-use WYSIWYG editor is popular with our site’s users, sometimes I find it gets in the way, and want to turn it off.
disableWysiwyg.png

Continue reading

Maximizing the Captivate window automatically

We found that some of our users did not know how to maximize windows (or even that it was possible!), and so never saw the navigation bar and buttons on the bottom of a Captivate-based course they had to take.

The customer who designed the course asked that we add instructions on maximizing the window, but I thought that it would make more sense just to make the window maximize itself.

It’s been a while since I used window sizing functions, so I went hunting for a script that works across all browsers.

After trying several, I found that some “auto-maximize window” scripts don’t even work every time on ANY browser. The one that worked best on every browser I tested it on is available free from Dynamic Drive, here.

Continue reading

Internet Explorer 7 blocks cross-domain iframe to parent communication

A new security setting in Microsoft Internet Explorer 7 has been causing problems with requests between iframe and parent. There is a security setting in the Internet options called “Navigate sub-frames across different domains”, which in IE6 was set to “Enabled” under Medium security, but is set to “Disabled” in IE7 by default.

An example of the type of communication that is blocked is shown here:

The container page sends a message to Page 1, in Domain A: “Change your location to Page 2”. In IE6, this is not a problem. But in IE 7, it is allowed.

Continue reading

Getting the value of a variable on the opener page from a popup window

How do you use javascript to get the value of a variable on the opener page, from a popup window? Use “window.opener.variablename“. This will work as long as the pages are in the same domain.

It consists of 2 pages. On the first page, a variable “timer” has been defined, and it automatically increments upward every 5 seconds. The current value is displayed in a div on the opener page.

Continue reading

Use ABCpdf to generate pdfs of multi-paged html documents

I maintain a library of learning modules which are constantly under development and revision. Our users often want PDFs to print out or view off-line, but we can’t maintain up-to-date PDF’s of each module manually. We needed a way to make on-demand PDFs of whatever the current state of the module is when the pdf is requested.

After looking at many pdf solutions I settled on “ABCpdf ASP 6.0” by WebSuperGoo.com.

ABCpdf has the advantages of fairly low cost (about $400.00 for one server, or FREE if you link back to them), a better HTML-rendering engine than most, and an easy to learn API, so you can write custom dynamic PDF applications.

Continue reading

Timing Issues and Javascript

Sometimes, when you use javascript to make a change to some element on a page, you will get a Javascript error along the lines of: “element ‘n’ has no properties.” You check your page, and yes, the element is definitely there, and it is definitely named correctly, and your syntax is definitely correct. So where is the problem?

Well, it may be a timing issue. If your script executes before the element targeted by the script has been rendered, it will not find the element. This can particularly be a problem with frames or iframes. The solution is to move the function call to the bottom of the page, after the element has loaded.

Continue reading

Detect browser support for style properties

It is common to use object detection to discriminate between browser capabilities (See Quirksmode: Object Detection.

However, sometimes it is necessary to detect whether or not a browser understands a particular CSS style property, and it is not obvious how to do this.

You can’t test for the existence of the property directly but you can test for the data type of the value of the property. If the data type is anything but “undefined”, the property is understood by the browser.

The example below shows a couple of rows from an automatically generated table of items. Each row has a corresponding editable version which shows up when the “edit” button is clicked. The original, non-editable row is hidden at the same time the editable row is displayed. If “display=’block” is used to display the TR, Safari will render it as a TD. To correct this, “display=’table-row” must be used on browsers that understand it.

Continue reading