Function with arguments not working with window.onblur and onfocus

Function with arguments not working with window.onblur and onfocus

The following code isn't working

  1. window.onfocus = welcome("John Doe"); window.onblur = bye("John Doe"); function welcome(name) { $("p").append("Welcome back " +name+ " <br>"); } function bye(name) { $("p").append("Good bye " +name+ " see you soon <br>"); }
However I noticed that this code works for custom functions that dont take any argument. See code below. The following code is working:

  1. window.onfocus = welcome; //No Argument here so this code works window.onblur = bye; //Same here... No argument for the function function welcome(name) { $("p").append("Welcome back John Doe <br>"); } function bye(name) { $("p").append("Good bye John Doe see you soon <br>"); }
I am new to jquery and javascript and this stuff is confusing me. Can someone please explain why exactly it isn't working. and how can I make a custom function with arguments work with window.onfocus and onblur method. (reason for working or not working is more important for me as I want to understand the mechanics rather than cramming up the snippets)