You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tapestry.apache.org by Peer Brink <pe...@gmail.com> on 2008/08/05 13:54:27 UTC

Getting users timezone-offset (javascript)

Hello,

I need to know the users/browsers timezone-offset on the server. The
offset can easily be retrieved by some javascript on the client:

var offset = new Date().getTimezoneOffset();

But how can it be transmitted from the client to the server?

I read through quite some pages about javascript, JSONObjects, Ajax,
etc. but I still don't see the solution.

Sorry for this rookie-question. Any help is very much appreciated.

Thanks,
Peer.

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
For additional commands, e-mail: users-help@tapestry.apache.org


Re: Getting users timezone-offset (javascript)

Posted by Peer Brink <pe...@gmail.com>.
On Tue, Aug 5, 2008 at 18:59, Josh Canfield <jo...@thedailytube.com> wrote:
> I looked around a bit for a solution once and ended up just sticking the
> offset into a hidden form field.

Dear Josh,

this in fact is working and seems to be a quite simple solution
compared to other possibilties I was thinking of (JSON-Object for
example). Thanks a lot for this hint!

If anyone is interested in the details: I used the hidden field from
t5components:
http://87.193.218.134:8080/t5components/t5c-commons/ref/org/apache/tapestry/commons/components/Hidden.html
inside the form like this:
<hidden t:id="tzOffset" name="tzOffset" t:type="t5components/Hidden"
value="tzOffset"/>

And added some javascript to the site:
void setupRender() {
  renderSupport.addScript("document.myFormName.tzOffset.value = new
Date().getTimezoneOffset();");
}

Make sure to add attribute
name="myFormName"
to the <form>-element in your html.

The timeZone-Offset will then be transmitted using the usual
setter-method upon submission of the form.

This could be used for transmitting any data retrieved by javascript
from the client to the server unless there is no direct support in T5
for this.

Regards,
Peer.

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
For additional commands, e-mail: users-help@tapestry.apache.org


Re: Getting users timezone-offset (javascript)

Posted by Josh Canfield <jo...@thedailytube.com>.
I looked around a bit for a solution once and ended up just sticking the
offset into a hidden form field. If you need the offset from something other
than a form post then you'd have to do something more creative, like stick
it in a cookie or something.


On Tue, Aug 5, 2008 at 4:54 AM, Peer Brink <pe...@gmail.com> wrote:

> Hello,
>
> I need to know the users/browsers timezone-offset on the server. The
> offset can easily be retrieved by some javascript on the client:
>
> var offset = new Date().getTimezoneOffset();
>
> But how can it be transmitted from the client to the server?
>
> I read through quite some pages about javascript, JSONObjects, Ajax,
> etc. but I still don't see the solution.
>
> Sorry for this rookie-question. Any help is very much appreciated.
>
> Thanks,
> Peer.
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
> For additional commands, e-mail: users-help@tapestry.apache.org
>
>


-- 
--
TheDailyTube.com. Sign up and get the best new videos on the internet
delivered fresh to your inbox.