Activity Forums Salesforce® Discussions Difference between window.parent.location and window.top.location in salesforce? Reply To: Difference between window.parent.location and window.top.location in salesforce?

  • nick

    Member
    September 12, 2017 at 6:20 am

    Both are different, window.location is an object containing the property while location.href which is a string. The window.location is an object that holds all information about current document location (host, href, port, protocol etc.). The location.href is shorthand for window.location.href, and this is only string with full url to current website. The location object's toString() value is the same as the href property, so they are identical if used as strings. Setting window.location is the same as setting window.location.href.

    <script language="javascript" type="text/javascript">

    window.location.href = "http://www.example.com";

    </script>

     

    The above Javascript code sets the new href (URL) for the current window.