- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-28-2016 07:51 AM
Hi: We have the following script in our 'Resolve Now' UI action that is called every time the user clicks the 'Resolve Now' button:
if (typeof window == 'undefined') {
serverResolve();
}
I am wondering if something is wrong with the code. What is window == 'undefined'? Is it always 'undefined'? When is it 'defined'?
Thanks for your help!
Rita
Solved! Go to Solution.
- 29,318 Views

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-29-2016 05:39 AM
Hi Rita,
if(typeof window == 'undefined') means
1.Code that runs without 'onclick'.
2.Ensure call to server-side function with no browser errors
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-28-2016 07:56 AM
Hi Rita,
It's to test if the script is being run in a web-browser or not. In a webpage, there are several intrinsic objects, such as window, other environments (like Node.js) won't have window but might have other objects like console (well, console now exists in most browsers now, but it wasn't originally).
Thanks and Regards,
Vikas Malhotra
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-28-2016 08:03 AM
Hi Vikas and thank for your prompt response. So is it correct to be getting typeof window == 'undefined' if I'm using a web browser, which I am?
Regards, Rita
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-28-2016 08:19 AM
Hi Rita,
Yes, there may be a case when you get typeof window == 'undefined' if you are using a web browser like in case of web workers.
Hope this is helpful.
Thanks and Regards,
Vikas Malhotra
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-29-2016 05:35 AM
Hi Vikas: It appears that typeof window == 'undefined' always executes in UI Actions. So I am assuming that this is server side code that always executes regardless of browser. Thanks for your help. Rita