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

  • Home
  • SEARCH
  • 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 7526763
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T03:55:23+00:00 2026-05-30T03:55:23+00:00

As JSONP requests are created in the following way: var script=document.createElement(‘script’); script.src=’url’; script.onLoad=function(){dosomething()}; document.body.appendChild(script);

  • 0

As JSONP requests are created in the following way:

var script=document.createElement('script');
script.src='url';
script.onLoad=function(){dosomething()};
document.body.appendChild(script);

My question is that, is there a w3c standard, cross-browser supported event like onBeforeLoad which in turn let us stop executing downloaded script, in case it is not a well-formed JSONP response, or it is not passing through some predefined scheme validation, or just in case it consists of some harmful code(basic script validation)?
I know of the onBeforeLoad event supported in some browser out there, but focusing on the downloaded script datasource and in any of the reasons stated above,
it would be extemely useful to have cross-browser access to the loading script source, and due to good reasons,
the possibility to stop the execution, just before it is started.

For example the above script could be the following:

var script=document.createElement('script');
script.src='url';
script.onBeforeLoad=function(){
       if(json.parseJson(this.dataSource) && 
          json.validateAgainst(schema,this.dataSource))
       {
          return false;
       }
       else{
          return true;
       }
};
//if onBeforeLoad return true, onLoad will not be fired;
script.onLoad=function(){dosomething()};
document.body.appendChild(script);

I know that JSONP is all about trust in the 3rd party javascript module, hence i sometime wish that if i could validate those modules just before i am using it.

  • 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-30T03:55:24+00:00Added an answer on May 30, 2026 at 3:55 am

    If you want to detect whether the JSONP response is more than the JSONP you are expecting, then no, this is not possible.

    If you would be able to read the response, you wouldn’t need JSONP in the first place. Because the main reason to use JSONP is to circumvent the restrictions on accessing the response of XHR requests or via DOM due to the Same-Origin Policy. And the extension of XHR (formerly known as XHR Level 2) that allows cross-origin requests by supporting the CORS specification may not be applicable due to missing support by browsers and/or by servers.

    That’s the main security concern with JSONP: You need to trust the server.

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

Sidebar

Related Questions

All, I have the following JSON Request that comes through a function call in
The following function will pull down first X messages from Twitter firehose, but looks
I have an HTML document with the following form: <form> <input type=text id=price> <input
I am trying to get the list from server through javascript using following var
I'm struggling with the following problem: My App makes sequence of requests to the
I'd like to update a page based upon the results of multiple ajax/json requests.
I need to render JSON data in my JSPs for some AJAX requests. I'd
I am running a following code on Windows Phone: string baseAddress = tcAddress +
Following on this question I am actually in the phase of finding the right
I would be thankful for any help! I'm using the following code to create

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.