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

107
Views
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
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!