0

how to capture href onClick() event

asked 2009-06-18 03:30:54 +0800

gmitev gravatar image gmitev
190 3

How could I trap the onClick event when href is pressed?

If I override the method onClick() it will get called on all onClick() events, how to know that it has come from href?

The motivation behind this is that I would like to call one of my java methods when href is clicked.

delete flag offensive retag edit

4 Replies

Sort by ยป oldest newest

answered 2016-03-17 02:28:43 +0800

makarchus gravatar image makarchus
0

I have the same exact need. it would be wonderful if you can please let me know how to do that.

I tried using redirect but that initiate pop-up blocker functionality which mess up my user experience.

Ideally I would like to know when user has clicked the href link so I can track how many times the link is clicked from a particular zul file.

Thank you in advance for you help in this regard

link publish delete flag offensive edit

answered 2016-03-17 08:20:19 +0800

Darksu gravatar image Darksu
1991 1 4

Hello makarchus,

The ZK component reference for a button states the following:

The href property is processed at the client. In other words, the browser will jump to the URL specified in the href property, so your application running at the server has no chance to process it. If you have to process it at the server or you have to decide whether to jump to another URL based on certain condition, you could listen to the onClick event, process it, and then invoke Executions.sendRedirect(String) if it shall jump to another URL.

Reference:

http://books.zkoss.org/wiki/ZKComponentReference/EssentialComponents/Button#HrefandtheonClick_Event

So you should use the onClick event in order to accomplish your task.

Regarding the pop up blocker, are you creating a new tab or redirecting the page in the same tab?

Best Regards,

Darksu

link publish delete flag offensive edit

answered 2016-03-20 16:49:19 +0800

makarchus gravatar image makarchus
0

I am using this on iPhone and unless you change the setting for popup blocker, the new window opening does not work. Even after allow pops it prompts for opening a new window.

My ultimate goal is to track how many times people are clicking on one href link. I am unable to find how to track the click and update a count in database that this link was clicked.

Thank you for any help / ways you can recommend.

link publish delete flag offensive edit

answered 2016-04-03 09:13:47 +0800

Darksu gravatar image Darksu
1991 1 4

Hello makarchus,

As a solution for the counter, you could add a url parameter (i.e current date-time using a format yyyymmdd or even just a simple value) and send it with the request.

http://books.zkoss.org/wiki/Exampleofexecution_getParameter

The window that will open will check, parse the parameter, and then it will update the database table accordingly.

Best Regards,

Darksu

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: 2009-06-18 03:30:54 +0800

Seen: 342 times

Last updated: Apr 03 '16

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