html的多个内嵌注释 [英] Multiple inline comments for html

查看:185
本文介绍了html的多个内嵌注释的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图评论以下HTML,以便它不应该超链接。

 < a href = <!--http://www.google.com=--> target =_ blankonclick =javascript:alert('Navigation Prevented')>点击此处为GOOGLE< / a> 

我无法评论target =_ blank。如果我这样做它不工作,它在页面上显示javascript。



如何获得页面显示提醒,以及在新标签页中停止打开页面。我想要取消target =_ blank的效果。



我们不能在html中内置多个注释。



您可以在HTML标签中使用HTML注释,因为注释是标签本身。您可以从事件处理程序返回 false ,以阻止浏览器关注链接:

 < a href =http://www.google.comtarget =_ blankonclick =javascript:alert('Navigation Prevented'); return false;> CLICK HERE FOR GOOGLE< a> 


I am trying to comment the following html so that it shouldn't go to hyperlink.

<a href="<!--http://www.google.com=-->" target="_blank" onclick="javascript:alert('Navigation Prevented')">CLICK HERE FOR GOOGLE</a>

I am unable to comment target="_blank". if I do so it doesn't work and it displays javascript on page as well.

How do I have the page display alert as well as stop opening the page in new tab. I want the effect of target="_blank" to be cancelled.

Can't we have multiple comments inline for html.

解决方案

You can't have HTML comments inside an HTML tag, as the comment is a tag itself.

You can return false from the event handler to keep the browser from following the link:

<a href="http://www.google.com" target="_blank" onclick="javascript:alert('Navigation Prevented');return false;">CLICK HERE FOR GOOGLE</a>

这篇关于html的多个内嵌注释的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆