javascript - js ecwid url redirect -


i have been trying set redirects range of ecwid urls starting /shop /shop#!/~/ lead /shop#!/~/cart

i have come code:

var wrong_url = ['http://example.com/shop','http://example.com/shop#','http://example.com/shop#!','http://example.com/shop#!/','http://example.com/shop#!/~','http://example.com/shop#!/~/'];  var current_url = document.url;  (i=0;i<wrong_url.length;i++) {      if (current_url==wrong_url[i]) {      document.location.replace('http://example.com/shop#!/~/cart');      break;            }  }

it works right there problem. when @ /shop#!/~/cart , manually change url to, say, /shop#!/~/ won't redirected until refresh page. believe has ajax behavior of ecwid shopping cart can't figure out how fight it.

need help?

vitaly ecwid here.

the issue in current version of script doesn't detect changes url described.

so need create handler such situations separately. example, can this:

<script> var wrong_url = ['http://example.com/shop','http://example.com/shop#','http://example.com/shop#!','http://example.com/shop#!/','http://example.com/shop#!/~','http://example.com/shop#!/~/']; var current_url = document.url;  // function check current url , make redirect function checkurl(){     (i=0;i<wrong_url.length;i++) {       if (current_url==wrong_url[i]) {       document.location.replace('http://example.com/shop#!/~/cart');       break;             }   } }  // execute checkurl() function each time url changed $(window).bind('hashchange', function() {   checkurl(); });  // execute checkurl() function on initial page load checkurl(); </script> 

Comments

Popular posts from this blog

java - SSE Emitter : Manage timeouts and complete() -

jquery - uncaught exception: DataTables Editor - remote hosting of code not allowed -

java - How to resolve error - package com.squareup.okhttp3 doesn't exist? -