views:

22

answers:

1

If I set:

<img src="test-àè" onclick="alert(this.src);">

on FF the alert shows an escaped message: test-%C3%A0 while on IE it shows the unescaped version: test-àè

I'm using:

<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"&gt;

in my page and windows-1252 encoding

<meta http-equiv="Content-Type" content="text/html; charset=windows-1252">

Do you know why is this happening?

A: 

It's because firefox (and Chrome too) automatically URL encodes your the src because it is assumed to be a URL.

Here's a little test:

<img src="test-àè" foo='test-àè' onclick="alert(this.src);alert(this.getAttribute('foo'));">

In ie you get 'test-àè' 2 times. In Firefox you get 'test-àè' only the second time.

Matthew Smith