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

Notifications

Announcements

No record found.

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)
  • Verified answer
    gdas Profile Picture
    50,091 Moderator on at

    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.

  • Community Member Profile Picture
    on at

    Perfect. Thank you. :-)

  • nickmanny Profile Picture
    136 on at

    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.

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…

Neeraj Kumar – Community Spotlight

We are honored to recognize Neeraj Kumar as our Community Spotlight honoree for…

Leaderboard > 🔒一 Microsoft Dynamics CRM (Archived)

#1
SA-08121319-0 Profile Picture

SA-08121319-0 4

#1
Calum MacFarlane Profile Picture

Calum MacFarlane 4

#3
Alex Fun Wei Jie Profile Picture

Alex Fun Wei Jie 2

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans