Using onclick for the same tab/window and href for new tab/window

42 views Asked by At

I am fairly certain this has been asked before but I couldn't find a relevant post after a good amount of searching.

We have a site with product listings on a page. The page has a header, footer and a content section (div) in between. Upon clicking the product listing image, the content section is rendered with a new template and JSON from a REST API. We use jQuery to achieve this. Nunjucks is the templating engine we use.

We basically use a AJAX call to fetch the JSON from the backend and then render the appropriate nunjucks template on the browser with the JSON.

The problem is that this doesn't seem to be able to handle Right-click -> Open in new tab events. Since the new tab has no url, its coming up empty.

How can we handle this scenario where we go with an AJAX DOM update (partial page update) if the link is opened in the same window/tab and load a the full URL if the link is opened in a new window/tab ?

0

There are 0 answers