javascript window.onLoad not called

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

javascript window.onLoad not called

Joseph Blatter
Hi. My problem is that Seaside isn't calling a javascript window.onload event handler. I've defined this handler in a javascript file like this:

window.onload = function(e) {
  var cookie = readCookie('mycookie');
  var title = cookie ? cookie : getCurrentTitle();

  alert('hi this isn't working');
  setCurrentTitle(title);
}

window.onunload = function(e) {
  var title = getActiveTitle();
  createCookie('mycookie', title, 365);
}

Then I've made a #script method in a WAExample class with the contents of this .js. I need the framework to call the onLoad event and execute that function, but when I enter the pages nothing happens. This is the expected behavior? Should I add something else to my component?
I'm using Seaside2 (2.7a1.mb210).
There's any way to solve this?
thanks



__________________________________________________
Correo Yahoo!
Espacio para todos tus mensajes, antivirus y antispam ¡gratis!
Regístrate ya - http://correo.espanol.yahoo.com/
_______________________________________________
Seaside mailing list
[hidden email]
http://lists.squeakfoundation.org/cgi-bin/mailman/listinfo/seaside
Reply | Threaded
Open this post in threaded view
|

Re: javascript window.onLoad not called

Lukas Renggli
> Hi. My problem is that Seaside isn't calling a javascript window.onload
> event handler. I've defined this handler in a javascript file like this:
>
> window.onload = function(e) {
>    var cookie = readCookie('mycookie');
>    var title = cookie ? cookie : getCurrentTitle();
>
>   alert('hi this isn't working');
>    setCurrentTitle(title);
>  }
>
> window.onunload = function(e) {
>   var title = getActiveTitle();
>   createCookie('mycookie', title, 365);
> }
>
> Then I've made a #script method in a WAExample class with the contents of
> this .js. I need the framework to call the onLoad event and execute that
> function, but when I enter the pages nothing happens. This is the expected
> behavior? Should I add something else to my component?
> I'm using Seaside2 (2.7a1.mb210).

The problem is that you directly assigning a function to onLoad using
Javascript: Seaside defines its own onLoad attribute in the body-tag
and therefor overrides your code. Have a look at
http://www.quirksmode.org/js/events_tradmod.html to learn about the
problems with your approach.

Better use the approach shown here
http://www.quirksmode.org/js/events_advanced.html or one of the
convenience methods several libraries like Prototype or Mootools
provide.

Lukas

--
Lukas Renggli
http://www.lukas-renggli.ch
_______________________________________________
Seaside mailing list
[hidden email]
http://lists.squeakfoundation.org/cgi-bin/mailman/listinfo/seaside