The CreatorCon Call for Content is officially open! Get started here.

How to get URL of current page in service portal

k_jayanth
Tera Contributor

I need to fetch the URL, when i select an item from the category.

function onload()

{

var href = window.location.href;

  alert('href       ' + href);

var what = getTopWindow().location.toString();

  alert('TW       ' + what);

}

These alerts works for catalog items but does not display when i load the item on service portal.

Thanks and Regards

Jayanth

1 ACCEPTED SOLUTION

parameswar
ServiceNow Employee
ServiceNow Employee

Hi,


If you don't find window object then try using 'this' object.



example:


this.location.href


View solution in original post

7 REPLIES 7

You peaked my interest, when you log "this", this is what you get. I didn't see any reference to page but it does hold reference to the bootstrap column and containers though.



find_real_file.png


So, using "this" does work?  The reason I ask is we are migrating from CMS to SPortal, and I'm looking at a way to redirect to a specific page in the SPortal, based on the selected choice in a drop down select box.  And if this is the same Tim Woodruff from the Pakt Pub videos on Safari/O'Reilly, then cheers to you for all your hard work with those videos!

 

Yes I can confirm that "this" works  this.location.href