window.open() not working
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-17-2014 05:48 AM
Hello,
I am trying to open a newly created knowledge article in a new window. I am using a UI Action. The following code does not work:
var sysid = kbArticle.sys_id;
var url = 'kb_knowledge.do?sys_id=' + encodeURIComponent(sysid);
url += '&sysparm_stack=/kb_knowledge.do?sys_id=' + encodeURIComponent(sysid);
url += '&sysparm_view=default_view';
window.open(url);//,'','width=800,height=700');
The error logs gives me the following:
org.mozilla.javascript.EcmaError: "window" is not defined.
Caused by error in <refname> at line 28
25: var url = 'kb_knowledge.do?sys_id=' + encodeURIComponent(sysid);
26: url += '&sysparm_stack=/kb_knowledge.do?sys_id=' + encodeURIComponent(sysid);
27: url += '&sysparm_view=default_view';
==> 28: window.open(url);//,'','width=800,height=700');
29:
But if I have the following line, it opens the knowledge article in the same window.
action.setRedirectURL(kbArticle);
Can anybody point out why the article does not open in a new window? Any help would be greatly appreciated.
Best Regards,
Shalini
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-31-2016 10:00 AM
Hi Shalini,
what if you use the following:
var sysid = kbArticle.sys_id;
var url = 'kb_knowledge.do?sys_id=' + encodeURIComponent(sysid);
url += '&sysparm_stack=/kb_knowledge.do?sys_id=' + encodeURIComponent(sysid);
url += '&sysparm_view=default_view';
top.window.open(url);//,'','width=800,height=700');
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-31-2016 10:21 AM
Thank you Victor!
This was a very old question (more than 2 year back) and I think we had figured out the solution.
Thanks for your reply.\
//Shalini
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-31-2016 10:15 AM
Shalini,
This article may be of some use to you. In order for a UI action to run on the client side, you need to make sure the "Client" checkbox is checked. Both "top.window" and "window" will be defined in that case. Hope this helps!