Skip to main content
Inspiring
May 24, 2017
Question

close current window button

  • May 24, 2017
  • 1 reply
  • 2289 views

I need to set up a close this window button on my animate project.

Currently I have set up the open.window() javascript

function openFunction(link) {

    window.open(link.href);

on the html page that my project is opened from and when I add the close.window() javascript

<!--start close window-->

function closeFunction() {

    window.close();

}

to the html5 page after it is published it works but I would prefer to build the close button in the Animate file so I don't overwrite the code when making an update.

I've tried the following actions in Animate and it doesn't work.

//close current window

this.closeWinBtn.addEventListener("click", closeCurrentWindow.bind(this));

function closeCurrentWindow()

{

  this.window.close();

  }

I believe I'm close. Any suggestions?

thank you

    This topic has been closed for replies.

    1 reply

    Legend
    May 24, 2017

    Why did you stick "this" in front of window? Window is a global object.

    In fact since the only thing your click handler function does is call another function, you can just call that function directly:

    this.closeWinBtn.addEventListener("click", window.close);

    nancyjo1Author
    Inspiring
    May 25, 2017

    Hello,

    I appreciate your assistance.