My lightning component (V40/SU17) errors out when accessed via MS Edge with LockerService enabled. Is there a different method of accessing the window.location?


<aura:component implements="forceCommunity:availableForAllPageTypes" access="global" >
    <aura:attribute name="url" type="String" />
    <aura:handler name="init" value="{!this}" action="{!c.doInit}" />


    doInit : function(component, event, helper) {
        component.set("v.url", window.location.href);


<aura:application >
    <c:WindowLocation />

Here's the error when viewed in MS Edge

enter image description here

This page has an error. You might just need to refresh it. Action failed: c:WindowLocation$controller$doInit [WeakMap.prototype.set: 'key' is not an object] Failing descriptor: {c:WindowLocation$controller$doInit}

  • I am facing the same problem. When I load jquery2.2.4 in to lightning component and try to open a component page, I got this error from the jquery library, since in the library they are using windows.location. Do you have a work around for this problem?
    – bluecat
    Jul 24, 2017 at 21:54

4 Answers 4


Just verified that this is the behavior we see too. It appears to be a bug in MS Edge. See related discussion and link to MS Edge bug. https://github.com/emberjs/ember.js/issues/15249 https://developer.microsoft.com/en-us/microsoft-edge/platform/issues/12112572/

  • I'll remove my answer, since it's incorrect. Thanks for the info!
    – sfdcfox
    Jun 1, 2017 at 20:24
  • 1
    What did you think it was originally, @sfdcfox?
    – Jan Julian
    Jun 2, 2017 at 20:05
  • @jmrjulian I thought it was a bug with LS. This answer says it's a browser bug, which makes sense.
    – sfdcfox
    Jun 2, 2017 at 21:33
  • Does anybody know any temporary workaround or any alternative way for this?
    – Sarang
    Sep 7, 2017 at 12:32
  • ^ bump. Could it be an issue with how redirects are implemented such that a workaround is linking to a URL in a different way? Sep 11, 2017 at 17:16

Instead of using window.location.href , you can just define an attribute in your component

    <aura:component implements="forceCommunity:availableForAllPageTypes" access="global" > <aura:attribute name="url" type="String" /> <aura:handler name="init" value="{!this}" action="{!c.doInit}" /> <p>{!v.url}</p>
<aura:attribute name ="url" type="String"/>


And also add an attribute to push URL variable from your lightning app and set in your component.

    <aura:application >
<aura:attribute name ="url" type="String"/>
 <c:WindowLocation  url="{!v.url}/>

*I've used this approach to get URL parameters and instead of splitting URL from getting it using location.href. while in your case you can try to get URL using $A.get('$Resource.SLDSv2') *


If you use window.location or location.href or anything to do with the window location object, there is a good chance Lightning will throw this error back at you - [WeakMap.prototype.set: 'key' is not an object].

If you wish to fetch the URL, use document.URL.

If you wish to set the URL (redirect), use document.location = https://your-url.com.

These 2 solutions for getting and fetching the URL should work in all browsers, so you do not need to do any browser / feature detection and write separate code for separate browsers.


Use "window.document.URL" instead of "window.location". That was the only way I could solve a similar problem.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .