根据用户是否拥有 Mac 或 PC 更改链接目标
是否可以根据用户使用的是 Mac 还是 PC 来更改链接的目的地?
举个例子:Apple 网站允许下载 Quicktime,但它“知道”您使用的是 Mac 还是 PC,并将您引导至相关页面。
这样做的背景/原因:我为某人建立了一个网站,他们那里有许多音频和视频文件。理想情况下,他们希望这样,如果用户使用 Mac,它将下载该文件的 QuickTime 版本,但如果用户使用 PC,它将下载 Windows Media Player 文件。
干杯
克里斯
Is it possible to change the destination of a link based on whether the user has a mac or a PC using javascript?
To give an example: The Apple website allows download of Quicktime but it "knows" whether you are using a mac or a pc and directs you to the relevant page.
Background/Reason for doing this: I have built a website for someone and they have a number of audio and video files on there. Ideally they want it so that if the user is on a mac it will download a quicktime version of the file but if they are on a PC it will download a Windows Media Player file.
Cheers
CHRIS
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
您可以检查 UserAgent 标头来区分 Mac 和 PC 浏览器。
You can check the UserAgent header to tell Mac and PC browsers apart.
是的。这并非万无一失,但可以做到。 这里是检测操作系统的 Javascript 示例。您可以简单地根据结果选择显示不同的
div
或类似的内容。Yes. It's not foolproof, but can be done. Here's a sample of Javascript detecting your OS. You could simply opt to display a different
div
or something similar depending on the result.示例
以下是http://www.java2s.com/Code/JavaScript 的 /Development/Getusersoperatingsysteminformation.htm
Here is an example
from http://www.java2s.com/Code/JavaScript/Development/Getusersoperatingsysteminformation.htm