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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 29, 20262026-05-29T20:08:45+00:00 2026-05-29T20:08:45+00:00

I know the solutions for cross browser domain calls. Either use JSONP, do a

  • 0

I know the solutions for cross browser domain calls. Either use JSONP, do a proxy call, or accept domains on server. I found 1 more strange way today at my company.

Method:

They are changing the host to match the host of second server by using this –

window.location.host = "xyz.com";
          or
document.domain = "xyz.com";

Then they are creating a hidden iframe and getting contents in iframe and replacing contents to visible element.

Problem:

It works with iframe but if I do ajax call, it doesn’t work. Any words on this?

  • 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-29T20:08:49+00:00Added an answer on May 29, 2026 at 8:08 pm

    i’m not a fan of jsonp, it creates coupling between data and presentation, and so i researched this issue before, and well, there’s a trick that you can use, follow this:

    let’s say we have the main window named A and the "child" window in the iframe named B.
    A and B must be served from the same host, but can have different subdomains, something like:

    A is served from sub1.example.com

    B is served from sub2.example.com

    browsers will let you change the domain of the document, but still restrict you on that, so you can only change the domain by removing subdomains until you reach the host, and so in A you change the domain, like so:

    document.domain = "example.com";
    

    in B you first make an ajax call to its domain (sub2.example.com), then after the first request was sent you change the domain just like in A, so that both documents have the same domain.
    since you made a request to the original domain in B the browser will allow you to keep sending requests to it, but since you also changed its domain, and now A and B have the same domain they can communicate with each other.

    it’s important that you first make at least one request in B to its original domain, before you change the domain.
    also, it won’t work if both pages are not served from the same host, so in most cases it does not solve the problem, but it does allow you a bit more room to maneuver.

    i used this trick more than once and haven’t came across any problems, as far as i’m aware, it works in all browsers, let me know if it doesn’t in some cases.

    here’s a pseudo example:

    in A
    ==================
    document.domain = "example.com";
    var child; // keep reference to B
    function setChild(win) {
        childDocument = win;
    }
    
    function handleMessage(message) {
        do what ever it is you need to
    }
    
    in B
    ==================
    make ajax request
    document.domain = "example.com";
    parent.setChild(this);
    
    function ajaxCallback(message) {
        parent.handleMessage(message);
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Does anyone know a cross-browser, reliable solution for catching presses of the tab-key in
Does anyone know of any reverse proxy solutions that allow the content/data of an
Do you know a good cross-browser way of knowing how wide will be a
ANSWER: The problem is that I am trying to make a cross-domain call using
I know there are multiple solutions online, but some are for windows, some are
Do you know a good source to learn how to design SQL solutions? Beyond
Firstly I know that there are many question and solutions to correct thread marshalling
I know a solution would be to use VS 2005 or 2008, but that's
I know one awkward solution for this taks will be : first use ct
Firstly, I'm not against Opera. It just seems when I encounter cross browser issues,

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.