如何将网页链接放入 JScript 警报对话框中?
我想在警报对话框中放置一个网页链接,以便我可以更详细地描述如何修复导致创建对话框的错误。
我怎样才能让对话框显示这样的内容:
There was an error. Go to this page to fix it.
wwww.TheWebPageToFix.com
谢谢。
I would like to put a link to a webpage in an alert dialog box so that I can give a more detailed description of how to fix the error that makes the dialog box get created.
How can I make the dialog box show something like this:
There was an error. Go to this page to fix it.
wwww.TheWebPageToFix.com
Thanks.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(7)
您可以尝试询问他们是否希望通过 window.prompt 进行访问:
此外,Internet Explorer 支持模式对话框,因此您可以尝试显示其中之一:
You could try asking them if they wish to visit via window.prompt:
Also, Internet Explorer supports modal dialogs so you could try showing one of those:
如果您确实愿意,您可以覆盖
alert()
函数的默认行为。 并不是说您应该这样做。下面是一个使用 YUI 库的示例,但您不必使用 YUI 来执行此操作:
基于 YUI 的警报框 - 替换丑陋的 JavaScript 警报框
If you really wanted to, you could override the default behavior of the
alert()
function. Not saying you should do this.Here's an example that uses the YUI library, but you don't have to use YUI to do it:
YUI-based alert box - replace your ugly JavaScript alert box
你不能 - 但这里有一些选项:
window.open()
- 创建自己的对话框prompt()
并指示用户复制 urlconfirm()
询问他们之后)div
并取消隐藏You can't - but here are some options:
window.open()
- make your own dialogprompt()
and instruct the user to copy the urlconfirm()
to ask them)div
on your page with a [FIX IT] button and unhide it你不能。 警报框不支持 html。 您应该将错误显示为页面的一部分,无论如何它比 JS 警报更好。
You can't. Alert boxes don't support html. You should display the error as part of the page, it's nicer than JS alerts anyway.
这是 JavaScript
alert()
所能做的最好的事情。 您的替代选择是尝试打开一个看起来像对话框的新小窗口。 使用 IE 可以打开它模式。That's the best you can do from a JavaScript
alert()
. Your alternative option is to try and open a new tiny window that looks like a dialog. With IE you can open it modal.即使可以,
alert()
框通常是模态的 - 因此从其中打开的任何页面都必须在新窗口中打开。 恼人的!Even if you could,
alert()
boxes are generally modal - so any page opened from one would have to open in a new window. Annoying!或者使用 window.open 并将链接放在那里。
Or use window.open and put the link there.