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

202
Views
How can I open a window after clicking a custom button?

So I got this code for a website using Tampermonkey, and I want it to open a window in the center of the screen after the button is pressed. How can I do that?

(function() {
    'use strict';
    //button
    var button = document.createElement("button");
    button.setAttribute("class", "mdl-button mdl-js-button geofs-f-standard-ui");
    button.setAttribute("id", "Button-toggle");
    button.setAttribute("style", "background:clear");
    button.innerHTML = "test";
    document.getElementsByClassName("geofs-ui-bottom")[0].appendChild(button);
    var buttonToggle = document.getElementById("Button-toggle");
    //Event Listener
    buttonToggle.addEventListener("click", function() {
        buttonToggle.setAttribute("style", "background:green");
        console.log("Button Pressed");
    });
})();
about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

You can open a new window with JavaScript It works on code pen well. https://codepen.io/ash_000001/pen/PoORmyg

You can change the position with this line of code:

const myWin = window.open("", "", "left=700, top=350, width=200, height=100");

function myFunction() {
const myWin = window.open("", "", "left=700, top=350, width=200, height=100");
let x = myWin.screenX;
let y = myWin.screenY;
document.getElementById("ao").innerHTML =
"myWin.screenX= " + x + "<br>myWin.screenY= " + y; 
}
<button onclick="myFunction()">Open Window</button>

<p id="ao"></p>

about 4 years ago · Juan Pablo Isaza Report
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!