what is the difference between window.open() and $window.open() methods.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-31-2022 06:11 AM
I see some of the widgets are using $window.open() and others are using $window.open().
Similarly, some are using window.postMessage() and others are using $window.postMessage().
Is there any difference between them like with/without "$" symbol infront of it. ??
Please let me know if you have any information.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-31-2022 06:16 AM
There is a great explanation here: https://docs.angularjs.org/api/ng/service/$window
In general, always use $window in widgets and remember to inject it to the controller 🙂
Best regards,
Sebastian Laursen
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-31-2022 06:27 AM
Hi Laursen,
Yes, I have checked this article about $window already.
In my scenario, I have to replace the usage of window objects with the Angular services in the widgets.
If I do that, will there be any difference in the usage or performance ? This I want to know.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-23-2023 12:01 AM
Hello @Ram118, did you get to know on the difference in usage/performance? Also, did you replace window with $window eventually?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-23-2023 12:34 AM
$window.open() vs. window.open():
- $window.open() is a ServiceNow-specific method provided by the GlideWindow API. It's used to open new windows or dialogs within the ServiceNow platform, providing additional control and customization options.
- window.open() is the standard browser JavaScript method used to open new browser windows or tabs. It's not specific to ServiceNow and can be used in any web context.
$window.postMessage() vs. window.postMessage():
- $window.postMessage() is a ServiceNow-specific method provided by the GlideDialogWindow API. It's used to send messages between a parent window and a child dialog or iframe window within the ServiceNow interface.
- window.postMessage() is the standard browser JavaScript method used to safely enable cross-origin communication between Window objects; it's often used to communicate between different tabs or frames in a web application, regardless of the platform.