Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

134
Vistas
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 Respuestas
Responde la pregunta

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 Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda