Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

133
Views
Workaround for Cross Domain Request

I am trying to execute the below code to open URL using javascript

var Urlone = document.getElementById('00N0b00'),

opening = window.open(Urlone),
            
opening.onload = function() {

var Urltwo = opening.document.getElementById('00GG')

window.open(Urltwo);}

This works and opens Urltwo when Urlone is from same domain as Origin URL, but Urltwo does not open when Urlone is from different domain than Origin.

I know its because or CORS standards, but I need help to get around this.

I already tried downloading chrome extensions which relaxes CORS but it did not work. I don’t want to use jquery or anyorigin.com. Looking for a possible solution using javascript.

about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

CORS (Cross-Origin Resource Sharing) is a system, consisting of transmitting HTTP headers, that determines whether browsers block frontend JavaScript code from accessing responses for cross-origin requests. (https://developer.mozilla.org/en-US/docs/Glossary/CORS)

You cannot inject JavaScript into a window when cross-origin resource sharing is disabled and this is by design.

Possible workarounds:

  • Change CORS headers on the server of Urltwo
  • Fetch source of Urltwo via an HTTP request and render it in a blank iframe (applicability will vary). Edit: If the request is initiated from JavaScript, this will be subject to CORS as well.

If you have access to the server serving Urltwo, changing CORS settings is the best solution. If you do not have access to the server, but you can edit the document served at Urltwo, you can communicate between the documents via document.postMessage (https://developer.mozilla.org/en-US/docs/Web/API/Window/postMessage) or by encoding information in the URL (query string or hash). If you have access to neither, you can use a proxy that fetches the contents at Urltwo, sents the correct CORS headers and sends the result back to you.

about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!