大网数据广告活动
网站运营与故障问答

Is it possible to change from domains to phrases in the URL bar?

· 52CE 我爱测

You can change a URL like google.com to google.com/test without reloading the page by JavaScript. Is it possible to completely change the URL like from google.com to Welcom.To.The.Website using the URL bar as a display?

问题原文

原帖链接 · Lorenzo Lapucci · CC BY-SA 3.0

You can change a URL like google.com to google.com/test without reloading the page by JavaScript.

Is it possible to completely change the URL like from google.com to Welcom.To.The.Website using the URL bar as a display?

已采纳解答

原帖链接 · MrWhite · CC BY-SA 3.0

Is it possible to completely change the url like from google.com to Welcom.To.The.Website

No, you cannot change the domain (ie. the origin). Presumably you are referring to HTML5's pushState()? From Mozilla Developer help:

The new URL must be of the same origin as the current URL; otherwise, pushState() will throw an exception.

Apart from being confusing for users. This would also be a security issue. Pretending to be a site you are not - phishing. A website could also trick you into visiting another malicious website just by hitting the back button.

摘自公开归档,保留原文语言,版式经整理,外部媒体与邮箱地址已移除。

资料来源与适用范围

资料来源
Webmasters Stack Exchange
适用范围
以原帖系统、软件版本与发布日期为准(2016-05-25)
内容语言
中文;命令、路径和错误标识保留技术原文
本地收录日期
2026-11-15
授权说明
CC BY-SA 3.0

正文与所需资源由本站本地存储。查看来源及更新记录 ↗

请按适用版本和实际日志确认原因;本站没有对每一种系统或设备逐项执行文中的操作。