简体   繁体   English

如何将用户从一个 url 重定向到另一个具有 JavaScript 操作(例如添加到购物车)的网站

[英]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.

相关问题 如何使用JavaScript将桌面用户重定向到一个站点并将移动用户重定向到另一个站点 - How can I redirect Desktop Users to one site and Mobile Users to another with JavaScript 如何从一个URL重定向到另一个URL? - How to redirect from one URL to another URL? 使用 Javascript 添加到另一个网站的购物车 - Using Javascript to add to another website's cart 如何将 url 重定向到另一个 url? - how can I redirect a url to another url? 如何使用 javascript(文件是本地文件)从一个 HTML 文件重定向到另一个文件? - How can I redirect from one HTML file to another using javascript (the files are local)? 我可以将javascript请求重定向到另一个javascript操作吗? - Can I redirect_to a javascript request to another javascript action? javascript倒计时结束后,如何将网站访问者重定向到另一个URL? - How to redirect a website visitor to another url after javascript countdown ends? Javascript - 如何将用户从旧 URL 重定向到新 URL,以便 SSL 证书匹配 - Javascript - how to redirect users from old URL to new one so SSL cert matches 如何自动从一个URL重定向到另一个URL - How to auto redirect from one URL to another 如何使用JavaScript将列表组之类的数据从一个HTML页面传递到另一HTML页面? - How can I pass data like list group from one html page to another using JavaScript?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM