空 HTML href 会导致 IE 中列出目录

发布于 2024-12-13 00:00:17 字数 409 浏览 5 评论 0原文

我有一个带有单独 HTML 文件的网站(实际上是 .shtml,但这对于这个问题来说并不重要)。这些 shtml 文件包含一张图片以及一个前进和后退按钮,因此我可以切换回预览 shtml 文件或浏览到下一个文件,就像在画廊中一样。所有这些 shtml 文件都是本地生成的。我用 Java 编写了某种生成器。基本上这是有效的,第一个 shtml 文件和最后一个指向 。当用户点击它时,什么也没有发生。这是预期的行为。它在 FF、Chrome、Opera 中进行了测试,并且可以在其中运行,但不能在 IE 中运行。当我在 IE 中单击“后退”或“下一步”时,我会看到目录列表。这是 IE 问题还是只是配置问题?也许我必须更改生成器代码,但如果不需要的话我不想这样做。那么还有其他解决方案吗?

I have a website with separate HTML files (actually .shtml, but this is unimportant for this issue). These shtml files contain a picture, and a forward- and backbutton so I can switch back to the preview shtml file or browse to the next one, like in a gallery. All these shtml files are generated locally. I wrote some kind of generator in Java. Basically this works, the first shtml file and the last points to <a href=""....>. When the users clicks on it, nothing happens. This is the expected behaviour. It was tested in FF, Chrome, Opera and it works there, but not in IE. When I click back or next in IE, I get the directory listing. Is this an IE problem or just a configuration issue? Probably I have to change the generator code but I don't want to if I don't have to. So is there another solution for that?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

凉薄对峙 2024-12-20 00:00:17

来自 http://msdn.microsoft.com/en-us/library /cc848861%28v=vs.85%29.aspx

如果将 HREF 指定为空白值(href="" 或 href=),则执行链接可能会显示包含当前文档的目录,或者可能会生成错误,具体取决于文档和服务器中的其他元素环境。

此行为是设计使然,没有解决办法。您必须想出一些不使用空白 href 值的内容,例如 href="#"

From http://msdn.microsoft.com/en-us/library/cc848861%28v=vs.85%29.aspx

If HREF is specified as a blank value ( href="" or href=), executing the link might display the directory containing the current document , or it might generate an error, depending on other elements in the document and the server environment.

This behaviour is by design and there is no work around. You'll have to come up with something that doesn't use a blank href value, such as href="#"

阳光的暖冬 2024-12-20 00:00:17

将其更改为

Change it to <a href="#"> or <a href="javascript:;">

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文