Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6542567
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T11:14:36+00:00 2026-05-25T11:14:36+00:00

I have a js widget which is embedded in random sites. When a user

  • 0

I have a js widget which is embedded in random sites.

When a user clicks a link I want to report it to my server.

To call my server I create a tag dynamically with src containing the parames reported to the server.

If I do it on onclick event and return true from the onclick, the server probably will not get the call because the browser changes the page (is this correct?).

If I do it on onclick and return false then use redirect after the call to the server is returned, I lose the back button functionality because browsers like IE do not support the back button after redirect.

Any idea of how to do this in a robust way?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-25T11:14:36+00:00Added an answer on May 25, 2026 at 11:14 am

    There is no problem. If you add an onclick handler to the <a> elements that sends an AJAX POST to the server (registering the click), this will arrive at the server, the page will still move on to the clicked link, and the back button will work as expected.

    Example in jQuery:

    $('a').live('click', function () {
         $.post('/registerclick/', { data: $(this).attr('src') }, function () {});
    });
    

    The reason this works, is because the client/server model in HTML specifies that when a request is sent to the server, it cannot be cancelled. Therefore the following applies:

    1. Event handler goes off, and a request to the server is sent
    2. User gets redirected by default browser behavior to the page in the href attribute
    3. Server gets the request, even tho the user is at a whole different page

    The browser isn’t aware of the 3rd step; but that doesn’t matter for the server.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

At the moment I have a widget which, when the user clicks on it,
I'm trying to create a widget (which is basically an iframe) that would have
I have a widget which is injecting a popup into different web sites, as
I have created a custom widget which has a link to some ajax functionality.
I have a JavaScript widget which provides standard extension points. One of them is
I have a JavaScript widget which communicates with my Rails app by creating tags
In a C# desktop application, I have a customer widget which contains a text
I have a JS script (widget) which is added to other websites. Technically its
I have a K* window, and within it, a widget which needs the events
Suppose I have a MyWidget which contains a MySubWidget , e.g. a custom widget

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.