kjs: variables with/without var

Koos Vriezen koos.vriezen at xs4all.nl
Sat Jan 18 15:24:06 GMT 2003


Hi,

This example uses a variable decl. without 'var'
  <HTML><HEAD><SCRIPT>
    function someFunc() {
      myvar = "test";
      alert(myvar);
    }
  </SCRIPT></HEAD>
  <BODY onClick="top.someFunc()"></BODY></HTML>
which works.

Now if I use it with frames it works only with 'var'.

  <HTML><HEAD><SCRIPT>
    function someFunc() {
      var myvar = "test";
      alert(myvar);
    }
  </SCRIPT></HEAD>
  <FRAMESET COLS="200,*">
    <FRAME SRC="frame.html">
    <FRAME SRC="frame.html">
  </FRAMESET></HTML>

where frame.html is

  <HTML><BODY onClick="top.someFunc()"></BODY></HTML>

If I ommit the 'var', someFunc() is never called (does work if I call it
with dcop ... evalJS 'top.someFunc()').
This used to work in kde-3.0.x btw.

Koos





More information about the kfm-devel mailing list