0

I have a javascript function load_url(url) that validates url and open relevant page.

function load_url(url) {

    // Performing some validation 
    // ...
    // ...

    window.location.assign(validatedUrl);
}

I have embedded load_url(url) in each href to open validated page. Like this

href="JavaScript:load_url('index.php?data=CreateBill')"

This function works normally when directly clicked but open blank page when user try to open it in new tab.

about:blank#blocked

Is there any way to open javascript function (embedded in href) to new tab?

Rashid
  • 1,244
  • 3
  • 13
  • 29
  • u could try to redirect to a .php script, grab the new url via $get, and redirect there. of course this is not plain javascript, so maybe you want to wait a little longer for better answeres – clockw0rk Jul 09 '20 at 12:34
  • I would check if user was holding ctrl key, and then open new tab for him with validated address. https://stackoverflow.com/questions/2445613/how-can-i-check-if-a-key-is-pressed-during-the-click-event-with-jquery – Kudlas Jul 09 '20 at 12:34
  • @Kudlas What if the user pressed middle mouse button? – clockw0rk Jul 09 '20 at 12:34
  • I guess you have to check that too. https://stackoverflow.com/questions/5392442/detect-middle-button-click-scroll-button-with-jquery – Kudlas Jul 09 '20 at 12:35

0 Answers0