1

I'm trying to use the window.location.assign to change my project page, but it's not working. The page I want to change is in the same folder.

My Code:

filterFunc (){
   window.location.assign("/teste");  
}

Failed to load https://console.bluemix.net/analytics/bmaid: No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'http://localhost:3000' is therefore not allowed access.

index.js:2178 +++DBDM-ERROR > getAnonymousID > Ajax call error. (Execution time: 309ms):

In the IDE it does not error, only on the page after clicking the button.

If someone has an idea of how to do it? Switch pages by clicking the button!

3
  • Could you use router BrowserRouter and redirect? Commented Apr 8, 2018 at 18:55
  • If you want to use assign method, you should pass URL as parameter instead of relative path Check Ref: developer.mozilla.org/en-US/docs/Web/API/Location/assign Commented Apr 8, 2018 at 18:58
  • you can also try window.location.href Commented Apr 8, 2018 at 19:04

1 Answer 1

1

The location.assign should work you are using the right methode only to need to change one thing

window.location.assign("/teste");

should be

window.location.assign("http://localhost:3000/teste");

this is also the way w3schools does it. But what I sad you're are on the right path.

Note: It is best practice to use window.location, this is supported by most browsers, eg: window.location = 'http://google.com'

Sign up to request clarification or add additional context in comments.

1 Comment

And also don't you use a extarnal package try to avoid that as much as possible. The more packages you use the more changed there are of you're application breaking with an update.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.