0

Executing javascript scrollTo function against a Window

asked 2008-11-13 19:57:50 +0800

ansancle gravatar image ansancle
327 9

I am trying to get the following to work - which it does not, since the scrollTo javascript function does not exist on the zk window object. How can I go about getting the true window object that will accept this function?

<?page zscript-language="javascript"?>
<window id="win">
<zscript>
    function hideURLbar()
    {
        win.scrollTo(0, 1);
    }
</zscript>
	<button label="Hide URL Bar on IPhone">
		<attribute name="onClick">
			hideURLbar();
		</attribute>	
	</button>
</window>

delete flag offensive retag edit

4 Replies

Sort by ยป oldest newest

answered 2008-11-13 20:02:53 +0800

huubf gravatar image huubf
69 1

updated 2008-11-13 20:03:12 +0800

to access clientside javascript you would have to use the action attribute

<button action="onclick:window.scrollTo(0,1)" />
onClick is a serverside click

link publish delete flag offensive edit

answered 2008-11-14 14:22:05 +0800

ansancle gravatar image ansancle
327 9

That definitely works as far as getting javascript to get called and run, I put in action="onClick:alert('foo');" to test and that worked. The scrollTo is still not working and I suspect that I am not actually getting to the javascript "window" object. How do I reference it inside the .zul file, do I use the zk id I have assigned or another method?
Thanks again for the help.

link publish delete flag offensive edit

answered 2008-11-14 14:57:13 +0800

ansancle gravatar image ansancle
327 9

I tried using the Clients class and it's scrollTo method with no luck getting the URL bar on the Itouch to hide.

<dhITouchWindow id="_zonesWindow" apply="com.dh.ui.itouch.composer.zone.DHzZonesComposer" onLoad="scrollTo()">
	<zscript>
void scrollTo()
		{
			Clients.scrollTo(0,100); 	  
	    }			
	</zscript>


link publish delete flag offensive edit

answered 2008-11-14 15:02:17 +0800

huubf gravatar image huubf
69 1

<button action="onclick:window.open()"/>
opens a window.

<button action="onclick:if(window.scrollTo) {alert('oke!');window.scrollTo(10,0);}"/>
one alert, no errors
Maybe scrollTo is not supported by all browsers, maybe you refer to win and is win not the browser window, maybe you use scrollTo in a faulty way.
I know nothing about scrollTo

regards, huub

link publish delete flag offensive edit
Your reply
Please start posting your answer anonymously - your answer will be saved within the current session and published after you log in or create a new account. Please try to give a substantial answer, for discussions, please use comments and please do remember to vote (after you log in)!

[hide preview]

Question tools

Follow

RSS

Stats

Asked: 2008-11-13 19:57:50 +0800

Seen: 361 times

Last updated: Nov 14 '08

Support Options
  • Email Support
  • Training
  • Consulting
  • Outsourcing
Learn More