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

115
Vistas
Program button to open new page if clicked when in iframe, but same page if clicked outside of iframe

I am creating a simple 'in-browser' python IDE (here: coder.computerscienceuk.com/coder) and have a save button which saves the editor code to a new URL.

How can I program the save button so that when visiting the main website it opens the new URL on the same page (as it currently does) but if the button is clicked from within an iFrame (embedded on another site) it forces the new URL to open in a new window/tab?

Here is my button code:

function remix(private) {
    var private = private;
    var codedata = myCodeMirror.getValue();
    var uid = $js_userID;
    var ide = $js_ide;
    var response;
    
    if (private == 1 && uid == 0) {
        alert("You need to be logged in to save to a private URL");
    } else {
        $.ajax({
    type: "POST",
    url: {$js_url} + '/wp-content/plugins/CSUKCODER/remix.php',
        data: {"codedata" : codedata, "uid" : uid, "ide" : ide, "private" : private},
        success: function(data) {
            response = data;
            response = response.replace('"','');
            response = parseInt(response);
            hashids = new Hashids();
            id = hashids.encode(response);
            window.open($js_urlpage + String(id), '_self')
        },
        error: function (request, status, error) {
            alert(request.responseText);
        }
    });
    };
}

<img src="$pluginRootPath/img/diskette.png" style="height:45px; padding-left:10px; cursor:pointer;" onclick="remix(0)" title="Save to URL">
about 4 years ago · Juan Pablo Isaza
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