Code Monkey home page Code Monkey logo

Comments (2)

pavelkomarov avatar pavelkomarov commented on August 16, 2024

Done, but it's goofy. The only way to log out seems to be to open the logout url on spotify's website, so clicking the logout button annoyingly opens a new tab. The alternative is to always face the user with a confirmation page every time they go through authentication with Spotify, which provides a "Not You?" link, but that's even more annoying.

I'd like to close the new tab automatically pretty immediately, but I haven't found a way to do it programmatically without interrupting the logout process.

from exportify.

pavelkomarov avatar pavelkomarov commented on August 16, 2024

Okay, I've worked it out. The issue is that when you make a popup window (or open a new tab) you can't control whether it has focus or not from the script. That's controlled by browser settings and whether the user was ctrl+clicking a link and whatnot. And once a different window has focus, the script from the previous window stops running and can't get focus back. This is to keep webpages from stealing back focus randomly and running in the background, which would be a nightmare for users. (Webpages can still throw alert()s to steal focus, but the user has to click "okay" before anything can advance.) So all my setTimeout() calls to .close() the new window weren't getting executed at all.

Solution: Load the page not in a new window but in an iframe, so the current script maintains control. Make the iframe invisible, because Spotify's homepage isn't interesting and can't be displayed through the frame anyway due to some security thing. Wait a second for the call to go through, then redirect to the homepage. User never has to leave the current tab and doesn't see the mess.

from exportify.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.