Opened 10 years ago

Closed 10 years ago

Last modified 9 years ago

#15861 closed defect (invalid)

on(window, 'onresize', ..... not working

Reported by: daniel.payne Owned by:
Priority: undecided Milestone: tbd
Component: Events Version: 1.8.0
Keywords: Cc:
Blocked By: Blocking:


does not work: on(window, 'onresize', testFunction);

does work: window.onresize = testFunction;

Test Code

<!DOCTYPE html> <html> <head> <meta charset="utf-8"/> <title>Test</title>

<meta http-equiv="Content-Type" content="text/html; charset=utf-8"> <!-- REMOVE FOR PRODUCTION --> <meta http-equiv="cache-control" content="no-cache"> <meta http-equiv="pragma" content="no-cache">

<meta name="viewport" content="width=device-width,initial-scale=1,maximum-scale=1,minimum-scale=1,user-scalable=no"/> <meta name="apple-mobile-web-app-capable" content="yes" />


var dojoConfig = {

isDebug: true, parseOnLoad: false, async: true



<script src=""></script>

<script >


"dijit/registry", "dojo/dom", "dojo/parser",



], function (registry, dom, parser, on) {


function testFunction(){


does not work on(window, 'onresize', testFunction);

if (window.onresize !== null) {

window.alert('on pass');

} else {

window.alert('on fail');


window.onresize = testFunction; if (window.onresize !== null) {

window.alert('assignment pass');

} else {

window.alert('assignment fail');





<body >

Test Complete

</body> </html>

Change History (5)

comment:1 Changed 10 years ago by freddefisk

I think that the event name should not start with "on", see

comment:2 Changed 10 years ago by bill

Component: GeneralEvents
Resolution: invalid
Status: newclosed


comment:3 Changed 9 years ago by Alexander Kläser

I just ran into the same problem. The following line would not work in Chrome 24:

on(window, 'resize', function() { console.log('window on resize') })

Could it be due to window.onresize being null initially?

comment:4 Changed 9 years ago by bill

Usually you have to wait to do commands until dojo/domReady!, but not sure of the rules if you are listening on the window object. If you have a test case that fails you should probably file a new ticket.

comment:5 Changed 9 years ago by Alexander Kläser

I was testing it live on the console, so the domReady was certainly not a problem. OK, I opened ticket #16763.

Note: See TracTickets for help on using tickets.