javascript - I need change this meta refresh redirect structure to window.location method -


i have web-app in nodejs make redirects in using method meta refresh. problem method incompatible firefox (in firefox not work meta refresh). , need redirect goes in browsers , versions. understand best way use window.location method, right?

the structure of code make actual redirect is:

module.exports = (outcome) => {   return "(function(document) {"+     "var meta = document.createelement('meta');"+     "meta.setattribute('http-equiv', 'refresh');"+     "meta.setattribute('content', '0;url=" + outcome + "');"+     "document.head.appendchild(meta);"+   "})(document);"; } 

how final code window.location method?

thank much!

you can use window.location.href.

a simple example be:

window.location.href = 'http://example.com'; 

or wrapped in function:

module.exports = (outcome) => {   return "(function(document) {"+     "window.location.href='" + outcome + "';"+   "})(document);"; } 

Comments

Popular posts from this blog

jOOQ update returning clause with Oracle -

java - Warning equals/hashCode on @Data annotation lombok with inheritance -

java - BasicPathUsageException: Cannot join to attribute of basic type -