Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

111
Visualizações
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 à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda