web
You’re offline. This is a read only version of the page.
close
Skip to main content
Community site session details

Community site session details

Session Id :
Microsoft Dynamics CRM (Archived)

Get window.location.href parameter

(0) ShareShare
ReportReport
Posted on by

Hi

This question is for CRM Online version 8.2.

How can I using javascript get a  window.location.href parameter? It does not return the same url as I see in the browser.

Thank you. 

*This post is locked for comments

I have the same question (0)
  • nickmanny Profile Picture
    136 on at
    RE: Get window.location.href parameter

    USE:

    window.location.replace('http://example.com');

    It’s better than using window.location.href = ‘http://example.com’;

    Using replace() is better because it does not keep the originating page in the session history, meaning the user won’t get stuck in a never-ending back-button fiasco.

    • If you want to simulate someone clicking on a link, use window.location.href
    • If you want to simulate an HTTP redirect, use window.location.replace

    You can use assign() and replace methods also to javascript redirect to other pages like the following:

    location.assign("">http://example.com");

    The difference between replace() method and assign() method(), is that replace() removes the URL of the current document from the document history, means it is not possible to use the “back” button to navigate back to the original document. So Use the assign() method if you want to load a new document, andwant to give the option to navigate back to the original document.

  • Community Member Profile Picture
    on at
    RE: Get window.location.href parameter

    Perfect. Thank you. :-)

  • Verified answer
    gdas Profile Picture
    50,091 Moderator on at
    RE: Get window.location.href parameter

    Hi ,

    Yes it is expected behavior ideally when you are retrieving the url form onload its basically triggering in content page  and its depends on where you are triggering javascript method  .

    You can try to add parent to get the top content URL.

    window.parent.location.href

    Hope this helps.

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Responsible AI policies

As AI tools become more common, we’re introducing a Responsible AI Use…

Andrés Arias – Community Spotlight

We are honored to recognize Andrés Arias as our Community Spotlight honoree for…

Leaderboard > 🔒一 Microsoft Dynamics CRM (Archived)

#1
Aric Levin - MVP Profile Picture

Aric Levin - MVP 2 Moderator

#2
MA-04060624-0 Profile Picture

MA-04060624-0 1

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans