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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 10, 20262026-05-10T17:09:26+00:00 2026-05-10T17:09:26+00:00

We have a project that generates a code snippet that can be used on

  • 0

We have a project that generates a code snippet that can be used on various other projects. The purpose of the code is to read two parameters from the query string and assign them to the ‘src’ attribute of an iframe.

For example, the page at the URL http://oursite/Page.aspx?a=1&b=2 would have JavaScript in it to read the ‘a’ and ‘b’ parameters. The JavaScript would then set the ‘src’ attribute of an iframe based on those parameters. For example, ‘<iframe src=’http://someothersite/Page.aspx?a=1&b=2&#8242; />’

We’re currently doing this with server-side code that uses Microsoft’s Anti Cross-Scripting library to check the parameters. However, a new requirement has come stating that we need to use JavaScript, and that it can’t use any third-party JavaScript tools (such as jQuery or Prototype).

One way I know of is to replace any instances of ‘<‘, single quote, and double quote from the parameters before using them, but that doesn’t seem secure enough to me.

One of the parameters is always a ‘P’ followed by 9 integers. The other parameter is always 15 alpha-numeric characters. (Thanks Liam for suggesting I make that clear).

Does anybody have any suggestions for us?

Thank you very much for your time.

  • 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. 2026-05-10T17:09:27+00:00Added an answer on May 10, 2026 at 5:09 pm

    Upadte Sep 2022: Most JS runtimes now have a URL type which exposes query parameters via the searchParams property. You need to supply a base URL even if you just want to get URL parameters from a relative URL, but it’s better than rolling your own.

    let searchParams/*: URLSearchParams*/ = new URL(     myUrl,     // Supply a base URL whose scheme allows     // query parameters in case `myUrl` is scheme or     // path relative.     'http://example.com/' ).searchParams; console.log(searchParams.get('paramName')); // One value console.log(searchParams.getAll('paramName')); 

    The difference between .get and .getAll is that the second returns an array which can be important if the same parameter name is mentioned multiple time as in /path?foo=bar&foo=baz.


    Don’t use escape and unescape, use decodeURIComponent. E.g.

    function queryParameters(query) {   var keyValuePairs = query.split(/[&?]/g);   var params = {};   for (var i = 0, n = keyValuePairs.length; i < n; ++i) {     var m = keyValuePairs[i].match(/^([^=]+)(?:=([\s\S]*))?/);     if (m) {       var key = decodeURIComponent(m[1]);       (params[key] || (params[key] = [])).push(decodeURIComponent(m[2]));     }   }   return params; } 

    and pass in document.location.search.

    As far as turning < into &lt;, that is not sufficient to make sure that the content can be safely injected into HTML without allowing script to run. Make sure you escape the following <, >, &, and ".

    It will not guarantee that the parameters were not spoofed. If you need to verify that one of your servers generated the URL, do a search on URL signing.

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

Sidebar

Ask A Question

Stats

  • Questions 67k
  • Answers 67k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • added an answer Textarea elements don't have an innerHTML property. Just read the… May 11, 2026 at 12:03 pm
  • added an answer We require register tag <%@ Register Src='../../UserControls/RoundedButton.ascx' TagName='RoundedButton' TagPrefix='ttl' %> May 11, 2026 at 12:03 pm
  • added an answer You can use something like this: Iterator<MemoryPoolMXBean> iter = ManagementFactory.getMemoryPoolMXBeans().iterator();… May 11, 2026 at 12:03 pm

Related Questions

We have a project that generates a code snippet that can be used on
We have a client that has Oracle Standard , and a project that would
We have a PHP project that we would like to version control. Right now
We have a VXML project that a 3rd party parses to provide us with
We have a netbeans project that has an xsd that we use to create
At the company I work for we have a Utility project that is referenced
We have a Silverlight 2 project (game) that will require a lot of character
We have a large MS Access project that requires GUI functionality that is difficult
I have a big project that was first created in Borland C++ 6. We're
In a legacy project that I'm on, we have several processing that are preformed

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

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.