Javascript 从 url 中删除符号 "amp;"

标签 javascript jquery html css

我有这个网址,我想删除“amp;”从中。任何想法

http://localhost/projects/opencart/opencart230/upload/index.php?route=product/product&product_id=40

最佳答案

考虑使用不包含 & 等 HTML 实体的 URL。如果出于某种原因,您无法在 URL 中避免使用它们,请执行以下操作来解析它们:

const url = "http://localhost/projects/opencart/opencart230/upload/index.php?route=product/product&product_id=40";
const parseResult = new DOMParser().parseFromString(url, "text/html");
const parsedUrl = parseResult.documentElement.textContent;
console.log(parsedUrl);

关于Javascript 从 url 中删除符号 "amp;",我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/46255110/

相关文章:

javascript - jQuery 窗口滚动动画

javascript - 在空数组上调用 Array.prototype.reverse()?

javascript - 在 Javascript/HTML 中使用 Web.config 应用程序数据

android - 在 iOS 和 Android 平台上销售具有 HTML5 界面的应用程序有什么障碍吗?

javascript - Chrome/谷歌分析-ga.js :1 Uncaught SyntaxError: Unexpected token ILLEGAL

javascript - 显示/隐藏按钮的条件渲染 - ReactJs

javascript - 检测触发表单提交的原因

php - POS : get a website to print directly to a defined local printer/s

javascript - 将 lat 长字符串转换为谷歌地图 API LatLng 对象

javascript - 匹配没有标签的 DOM 文本?