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

159
Vistas
How to use the XMLHttpRequest api to retrieve the title of the current page loaded in an iframe?

I'm working on a solid-js application that has an iframe containing a site. I am trying to obtain the title of the current page loaded in the iframe and not having the same domain name as my site. I would like to know if it is possible to get this title using the XMLHttpRequest api. Here is the code of my iframe:

<iframe
      width="100%"
      height="1300"
      id="iframeID"
      src="https://gkwhelps.herokuapp.com"
    ></iframe>
about 4 years ago · Santiago Trujillo
1 Respuestas
Responde la pregunta

0

It's not possible in front-end JavaScript alone, due to security restrictions - you can't do anything with a document in a different domain unless that domain has specifically set things up to allow you do interact with it, which is quite unusual.

But it's not impossible. If you set up an app on your own server, you can have your site make a request to your server-side app, and have your app then make a request to the external site, and then either return the text of the response to your client, or parse the response yourself and send the document title to the client.

For example, in an express server, node-fetch, and JSDom, you could do something like:

fetch('https://gkwhelps.herokuapp.com')
  .then(res => res.text())
  .then((responseText) => {
    const doc = new JSDOM(responseText);
    res.send(doc.title);
  })
  // .catch(handleErrors);

And then from the client, you just need to make a fetch or an XMLHttpRequest to your app, and the title will be returned.

about 4 years ago · Santiago Trujillo 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