-
FEATURED COMPONENTS
First time here? Check out the FAQ!
Dear All
Am quite new in web application field. My zk application need to fire some event when user resizes the browser window.
In my zul page I defined an "onSize" event to catch... But it seems this event is never fired when user resizes its window..!
What am I doing wrong?? Could somebody help me figure out?
Thanks in advance.
-nat
Hi Nat, i tried following:
<window title="My First Window" border="normal" width="200px" onSize='Messagebox.show("hey");' sizable="true"> Hello, World! </window>
and
<window title="My First Window" border="normal" width="200px" sizable="true"> <attribute name="onSize"> Messagebox.show("Hello"); </attribute> Hello, World! </window>
These two are for window's onSize event.
if you want to send a custom event, see:
"Inter-Page Communication" in developers guide. (so you know how to use sendEvent/postEvent).
I see...
Thanks Robertlee for your answer. If I understand, this event is fired only if window is sizable. It's maybe not exactly the kind of behavior am expexting.
What I want is the same behavior as in a normal html body tag like this:
<body onresize="resize()" >
...
</body>
I want to catch if user has resized browser window or not.
Thanks anyway and Season Greatings!
-nat
I am fighting since 3 weeks with this problem and haven't found a solution yet.
I suppose ZK cannot do this? catching the body onresize() event? I know it's possible (at least with html and jsp) but nobody has an idea how to do this with zk?
Do I have to mix html with zk in order to produce the desired effect or go back to my traditional jsp's?
Thanks anyway.
-nat
Hi nat,
Should this post explain:
http://bytes.com/groups/javascript/430012-body-onresize-vs-window-onresize
Regards,
Robert
Hi Robertlee
Am simply dazzed!.. So There is no onresize attribute for the body element in a Valid HTML?!! Woaw! I never know this before.
Is this meaning THERE IS NO WAY TO CATCH BROWSER RESIZE EVENT???
Thanks anyway.
-nat
Hi nat,
I have figured out a way, and I must say its a very interesting problem to me:
<?page title="new page title" contentType="text/html;charset=UTF-8"?> <zk> <window title="new page title" border="normal"> <script type="text/javascript"> window.onresize= message; function message() { var mye = document.getElementsByTagName('a'); for(i=0;i<mye.length;i++){ comm.sendEvent(mye[ i ], 'onUser', 'data from window'); } } </script> <div xmlns:h="http://www.zkoss.org/2005/zk/native" onUser='lab.value ="event caught by DIV " + org.zkoss.lang.Objects.toString(event.data); Messagebox.show("Do Task Here.")'> <h:a/> <label id="lab" /> </div> <div xmlns:h="http://www.zkoss.org/2005/zk/native" onUser='lb.value ="event caught by DIV " + org.zkoss.lang.Objects.toString(event.data)'> <h:a/> <label id="lb" /> </div> </window> </zk>
This method utilizes the comm function in ZK, by passing the event to the Server and blindly call getElementsByTagName to any 'a' tag. In effect to callback the onUser event listener to the parent of the 'a' tag.
It takes me a while to figure this out, you should buy me a beer if you find it useful.
Regards
Robert Lee
Hi Robertlee
Thank you very very much for your workaround... It seems somthing is happening: the onUser event is fired but i receive an error message stating: "Illegal Request: component is required for onUser".. I can't catch where the problem lies..
I took exactly the same code as you typed above... Could you please help more?
P.S: for sure, you deserve a full pint of beer!
-nat
Asked: 2008-12-16 08:55:54 +0800
Seen: 2,419 times
Last updated: Jan 20 '09