Internet Explorer cross-site scripting warning

I came across the warning “Internet Explorer has modified this page to help prevent cross-site scripting.” which is triggered by the IE8 security filter.

However, IE gives no clues of why the warning was triggered or what was modified to prevent it. Annoying.

To get some more information you must download Microsoft Application Compatibility Toolkit and run the Internet Explorer Compatibility Test Tool.

More information about this particular issue with XSS is available here.

It is possible to stop this warning from occuring (beside actually fixing the underlying issue) by adding a custom header entry: X-XSS-Protection: 0

Invalid JavaScript code error warning in NetBeans

Finally I managed to reproduce something that have been annoying me for several months while using NetBeans as my primary JavaScript editor:

netbeans-invalid-js-warning

Filed as issue #159060.

Update: Fixed in trunk and available in 6.7 M2. :-)

Virtual Earth point in bounding box test

I’m currently working with the Microsoft Virtual Earth SDK and wanted to test if a point is inside a box as where coordinates are specified using latitude and longitude.

It appears there are no built in function the API that does this, so this is what I came up with. Please note the special case where the bounding box overlaps the 180th degree longitude.

/**
* Returns true if point is in rectangle.
*
* @param {VELatLong} point Point to check.
* @param {VELatLongRectangle} rect Bounding box.
*/
function isPointInRect(point, rect) {
    return ( (rect.TopLeftLatLong.Longitude <= rect.BottomRightLatLong.Longitude && // longitude
              rect.TopLeftLatLong.Longitude <= point.Longitude &&
              rect.BottomRightLatLong.Longitude >= point.Longitude)
           || (rect.TopLeftLatLong.Longitude > rect.BottomRightLatLong.Longitude &&  // longitude crosses 180 degrees
              rect.TopLeftLatLong.Longitude >= point.Longitude &&
              rect.BottomRightLatLong.Longitude <= point.Longitude) )
           && (rect.TopLeftLatLong.Latitude >= point.Latitude &&     // latitude
              rect.BottomRightLatLong.Latitude <= point.Latitude);
}

This may be used, among many things, to test if a pushpin shape is within the current map view, and if it isn’t the map is panned to make it visible:

var point = shape.GetPoints()[0];
if (!isPointInRect(point, map.GetMapView())) {
    map.PanToLatLong(point);
}

Viewing Flash Player debug log flashlog.txt

Using the trace() function output is written to the file flashlog.txt if the debug version of Flash Player is used.

Verify that you are running the debug version at this page, if not you may download it here.

Then the Flash Player must be configured to enable logging using the mm.cfg file. It’s location is OS dependent, as well as the (hard-coded) location of the resulting flashlog.txt file. Location and possible settings of the mm.cfg file are documented here.

Using Mac OSX or Linux a convenient way to view the log file is to use tail -f from the command line, e.g.:

tail -f /Users/<user>/Library/Preferences/Macromedia/Flash Player/Logs/flashlog.txt

JavaScript Raster Bar Effect

I had some free time and wanted to bring back some early Amiga memories using JavaScript. Using canvas this is what I ended up with:

javascript-raster-bars

Click for demo.

I’m pleased the way the lightning and individual rotation of the bars themselves turned out to be. What do you think?