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 8063979
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T11:13:28+00:00 2026-06-05T11:13:28+00:00

I have a link as follows: <a onclick=runSomeJsonpCall(); href=www.goherenext.com> make this work </a> The

  • 0

I have a link as follows:

<a onclick="runSomeJsonpCall();" href="www.goherenext.com"> make this work </a>

The javascript method does your basic JSONP call, something like this:

function runSomeJsonpCall() {
var script = document.createElement("script");
script.src = "http://jsonpurl.com?parameter1=" + "someparam";
document.body.appendChild(script);
}

My JSONP call never actually executes, unless I put in return false to the onlick event, but then of course the href doesn’t navigate to the target.

How do I get both things to work?

NOTE: I can use pure JavaScript only, no libraries

  • 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-06-05T11:13:31+00:00Added an answer on June 5, 2026 at 11:13 am

    you should prevent default event …
    look there : event.preventDefault something like that …

    function runSomeJsonpCall(event) {
    
        if (!event) var event = window.event;
        if (event.preventDefault) {
           event.preventDefault();
        }else{
           // IE
           event.returnValue = false;
        }
        var script = document.createElement("script");
        script.src = "http://jsonpurl.com?parameter1=" + "someparam";
        document.body.appendChild(script);
    
       // you should wait for jsonp loading
       // here i use an ID to retreive  the element but you can do your way ...
       setTimeout("changeLocation('"+ document.getElementById('linkID').href +"')", 1000);
    }
    changeLocation(location) {
        window.location.href = location;
    } 
    

    Personnaly, i really don’t like the use of inline onclick attribute, i’ll use addEventListener or attachEvent … i think it’s a beeter way 🙂

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

Sidebar

Related Questions

I have link that calls a function when clicked: <a href=javascript:spawnMenu(this); id=link1>Test1</a> To make
I have a JavaScript link that is as follows: <a href=# onclick=window.open('TrackPackage.asp?track=235&ship=OTHER&ShippingMethod=1', '', 'location=1,menubar=1,scrollbars=1,status=1,resizable=1,width=635,height=460');
This is what I have basically: <a href=http://somelink.com> <span>stuff</span> <span onclick=AwesomeFunction();>more stuff</span> <span>the last
I'm using onClick in table rows as follows: <tr onmouseover=this.style.cursor='pointer' onclick=http://www.whatever.com/index.php?var={$foo1}> I also have
I have link for example domain.com/de/controler/action?param=value and I want make actionlink to keep same
I have an anchor link as follows: <a class=show-next-page id=10 href=# name=category rel=100000> And
Currently I have a link like follows: <a href=/myweb/cgi-bin/my.cgi?name=B. anthracis>B. anthracis</a> But instead of
if i have the following links : <a href="#" onclick="return navigateTo(this)" id="menuList:0:menu" class="normalLink"> <span
I have a link that opens a Thickbox... <a href=page.php?tag=lists-element&keepThis=true&TB_iframe=true&height=450&width=500> Everything works with this
I have a link to some style sheet from the Yahoo Developer Network, this

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.