Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我正在创建一个类似于谷歌图片的网站。当在 google 图像中单击(展开)图像时,url 将更改为 google 图像的特定图像。因此,当我在新的浏览器窗口中复制并粘贴该 url 时,相同的图像会展开。知道这是怎么做到的吗?还有如何缩短链接?
使用 JavaScript
pushState()
或者
replaceState()
replaceState() 将更改浏览器中的 URL
pushState() 将更改 URL,并将旧 URL 保留在浏览器历史记录中