use window.function worked