Skip to main content

Notifications

Announcements

No record found.

Microsoft Dynamics CRM (Archived)

Get window.location.href parameter

Posted on by Microsoft Employee

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

  • nickmanny Profile Picture
    nickmanny 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
    Community Member Microsoft Employee on at
    RE: Get window.location.href parameter

    Perfect. Thank you. :-)

  • Verified answer
    gdas Profile Picture
    gdas 50,085 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

December Spotlight Star - Muhammad Affan

Congratulations to a top community star!

Top 10 leaders for November!

Congratulations to our November super stars!

Tips for Writing Effective Suggested Answers

Best practices for providing successful forum answers ✍️

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 291,280 Super User 2024 Season 2

#2
Martin Dráb Profile Picture

Martin Dráb 230,214 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans