TMP notes on experiments on java. ============== alert() ============== alert()->null;, confirm(),-> true/false; prompt(str, str2)-> str Java: var r=confirm("Press a button"); confirm() returns true or false; depending on user pressing OK or cancel in the box. var s = prompt() returns user-entered string, unless pressed. HTML: ============== is-defined ============== isdefined(var): is that var def? if(typeof yourFunctionName == 'function') does it exist if(typeof myVar != 'undefined') then it is decl (w/w/o a value) if ("name" in window ) then name is decl i.e. window.name is valid ptr. instanceof() if (t1==undefined) shows that t1 exists, but has no value. o.prop === undefined is the way to go, or typeof(o.prop) == 'undefined' IFF you know 'o' is defined. o.prop == undefined is true if o.prop is defined, with the value null if (SomeObject.foo) works in javascript i.e. only true if var decl, and value assigned, and value not false/0/etc. NO: if (myvar) will throw an error if myvar is not decl. but if (window.myvar) will not be an err., just false. ============== Browser cmds ============== document.execCommand("cmd" ============== Window obj. ============== window.blur() .focus() window.find() .back(), .forward() Has win.frames 'window' seems to be: a) top java object = global scope. b) one particular window c) a frame A frame is an HTML and a DOM object, and hence a java object; and its field 'myframe.contentWindow' returns the window object. Window is not a DOM object, but a browser obj. 'window.self' is field that points to itself; and 'self' gets de-reffed to 'window.self'. The properties about whether the window is scrolling seems not to be settable via the window object. But the size probably can be and by 'resizeBy()'; and the position on the screen; and the (html) name. and focus(), blur() are about focus between windows. mywin.focus(); // bring it to front. But may have to call focus() from inside win. mywinptr.windowFocus=false; should work too but doesn't. self.blur works in safari, it doesn't in Firefox. Basically: the meaning of focus() is clear (seize the focus for that object from all others); but the meaning of blur() is less so (who should get the focus?): you need a list of the "sibs"; and particularly not clear for windows, since browsers may not let you have a list of the windows. So: can bring any window to the front with win3.focus() provided you have a ptr to that window. ============== Window opening ============== N.B. this makes all links be sent to the named window. ============== Window opening ============== http://www.infimum.dk/HTML/JSwindows.html Good doc on open() var mywin = window.open ("url","winName","location=0,width=300,height=214"); self.name = 'myHTMLname'; is supposed to add a name to the win. self.name = "Parent_Window"; useful so code in another window can refer to it. window.self: returns "current window" window.top: returns the topmost frameset window window.parent: returns the parent window (?if one win created others?? top, parent only relevant if using frames (it said). Frames are multi-level hier/tree, so top isn't always parent. window.opener: should return the window that did create it. using window.open() window.focus() will bring it to front (but .blur() doesn't work in firefox). window.scrollTo(100,500); self.resizeTo(screen.width,screen.height); self.moveTo(0,0); // to get it full screen. ============== FIND ============== window.find() pops up a dlog box for user ============== Query string building ============== Not built in; but can find code for function serialize() that will traverse DOM of
and build it. ============== Tags ============== ============== xx ============== ============== xx ============== ==============