[英]How can I redirect users from one url to another website that has a JavaScript action like add to cart
An example would be Website A has a product image that when you click on it, it redirects you to website B's cart page with the said product having already been added to the cart.一个例子是网站 A 有一个产品图片,当你点击它时,它会将你重定向到网站 B 的购物车页面,所述产品已经添加到购物车中。 Website B uses javascript to add to cart function.
网站 B 使用 javascript 添加到购物车 function。 Right now I'm redirecting users to the product page which is really not good user experience.
现在我正在将用户重定向到产品页面,这确实不是很好的用户体验。
If you want to redirect with JavaScript you could use window.location.href = "https://some url here"
如果你想用 JavaScript 重定向你可以使用
window.location.href = "https://some url here"
What that url would be is up to the site you want to redirect them to. url 将取决于您要将它们重定向到的站点。
Now, if website B uses URLs to add items to the cart, you would need to replicate such a url.现在,如果网站 B 使用 URL 将商品添加到购物车,您将需要复制这样的 url。 If it does not, and you have access to site B, you could add a listener to intercept such redirects.
如果没有,并且您可以访问站点 B,则可以添加一个侦听器来拦截此类重定向。
Otherwise, you may need to figure out some other mechanism, such as iframe and or proxy, it would depend on site B.否则,您可能需要弄清楚其他一些机制,例如 iframe 和/或代理,这将取决于站点 B。
You can use window.location
by passing the URL of website B您可以通过传递网站 B 的 URL 来使用
window.location
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.