Default value of JS window object

Harri Porten porten at trolltech.com
Fri Jul 5 15:54:52 BST 2002


On Fri, 5 Jul 2002, Koos Vriezen wrote:

> There is still a problem with JS code '"" + window'. It shows 'WARNING:
> Script threw exception: TypeError: No default value' at the console.
> Doing 'alert(window)' correctly shows '[object Window]'.

alert() calls the toString() C++ function on it's arguments. The attempt
to add a non-primitive object with a string will trigger a toPrimitive()
operation which is appearantly not implemented (see kjs/operations.cpp).

> Other objects than window/frame, do return a '[object XXX]' when doing a
> '"" + object'.

The window object is the most special object of all (as it's the global
object as well). I've added this case as a test to
khtmltests/ecma/location.html. Will look into this at home. Should be easy
to fix.

Question: have you encountered this problem in a real world web page ?

Harri.





More information about the kfm-devel mailing list