<a>标签中避免重复点击事件的发生

JSP与JS交互实操
本文详述了在JSP页面中使用JS实现按钮功能动态控制的方法,具体介绍了如何通过JS函数移除和重新设置按钮的点击事件,以及通过Ajax进行后台数据请求的过程。
jsp中:

<div class="layui-inline">
    <a class="layui-btn layui-btn-normal addNews_btn" onclick="batchAddItem()" id="changeGrn">批量选择</a>
</div>

js中:

//批量选择
function batchAddItem(){
     $("#changeGrn").removeAttr("onclick");
     Comm.ajaxPost('${ctx}/mes/manage/list/toAdd', {id: id}, function (res) {
          if (res.success) {
                 $("#changeGrn").attr("onclick","batchAddItem()");
          }
     }
}

 

 

<blockquote class="ReferenceQuote" style="padding-left:5px;margin-left:5px;border-left:#b6b6b6 2px solid;margin-right:0;"> -----原始邮件-----<br /> <b>发件人:</b><span id="rc_from">郭萌 <guomengcd@boe.com.cn></span><br /> <b>发送时间:</b><span id="rc_senttime">2025-09-25 16:50:08 (星期四)</span><br /> <b>收件人:</b> 郭萌 <guomengcd@boe.com.cn>, 朱学辉 <zhuxuehui@boe.com.cn><br /> <b>抄送:</b> <br /> <b>主题:</b> <br /> <br /> <p style="text-wrap-mode:wrap;"> <span style="font-family:"Microsoft YaHei";font-size:14px;line-height:1;">各位领导、同事好:</span> </p> <p style="text-wrap-mode:wrap;"> <span style="font-family:"Microsoft YaHei";"><span style="font-size:14px;">       </span><span style="font-size:14px;line-height:2;">感谢一直以来对“京东方电子科大研究院”工作上的支持,为了更好地提供平台服务,我们将定期进行项目推荐。以下为本期推荐卡,详情请点击下方目录阅览</span></span><span style="font-size:14px;font-family:"Microsoft YaHei";">:</span> </p> <div class="container" style="text-wrap-mode:wrap;"> <details><summary><span style="color:#337FE5;font-family:"Microsoft YaHei";"><span style="font-size:14px;"><b>基于铂系磷光分子的高性能深蓝光OLED</b></span></span></summary> <p> <span style="font-family:"Microsoft YaHei";font-size:14px;"><img src="/coremail/s?func=mbox:getComposeData&sid=*&composeId=1758790106104&attachId=1" alt="" width="640" height="360" title="" align="" /><br /> </span> </p> </details> </div> <div class="container" style="text-wrap-mode:wrap;"> <details><summary><span style="color:#337FE5;font-family:"Microsoft YaHei";"><span style="font-size:14px;"><b>OLED柔性屏印痕改善及叠层设计</b></span></span></summary> <p> <span style="font-family:"Microsoft YaHei";font-size:14px;"><img src="/coremail/s?func=mbox:getComposeData&sid=*&composeId=1758790106104&attachId=2" alt="" /><br /> </span> </p> </details> </div> <div class="container" style="text-wrap-mode:wrap;"> <details><summary><span style="color:#337FE5;font-family:"Microsoft YaHei";"><span style="font-size:14px;"><b>新型抗冲击、抗划痕柔性OLED盖板材料</b></span></span></summary> <p> <img src="/coremail/s?func=mbox:getComposeData&sid=*&composeId=1758790106104&attachId=3" alt="" /> </p> </details> </div> <div class="container" style="text-wrap-mode:wrap;"> <details><summary><span style="color:#337FE5;font-family:"Microsoft YaHei";"><span style="font-size:14px;"><b>双向高导热石墨膜</b></span></span></summary> <p> <span style="font-family:"Microsoft YaHei";font-size:14px;"><img src="/coremail/s?func=mbox:getComposeData&sid=*&composeId=1758790106104&attachId=4" alt="" /><br /> </span> </p> </details> </div> <div class="container" style="text-wrap-mode:wrap;"> <details><summary><span style="color:#337FE5;font-family:"Microsoft YaHei";"><span style="font-size:14px;"><b>相变热界面材料</b></span></span></summary> <p> <span style="font-family:"Microsoft YaHei";font-size:14px;"><img src="/coremail/s?func=mbox:getComposeData&sid=*&composeId=1758790106104&attachId=5" alt="" /><br /> </span> </p> </details> </div> <div class="container" style="text-wrap-mode:wrap;"> <details><summary><span style="color:#337FE5;font-family:"Microsoft YaHei";"><span style="font-size:14px;"><b>多模态触觉传感器</b></span></span></summary><summary><span style="color:#337FE5;font-family:"Microsoft YaHei";"><span style="font-size:14px;"><b><img src="/coremail/s?func=mbox:getComposeData&sid=*&composeId=1758790106104&attachId=6" alt="" /><br /> </b></span></span></summary></details> </div> <div class="container" style="text-wrap-mode:wrap;"> <details><summary><span style="color:#337FE5;font-family:"Microsoft YaHei";"><span style="font-size:14px;"><b>基于多孔MXene材料的柔性压阻式传感器</b></span></span></summary><summary><span style="color:#337FE5;font-family:"Microsoft YaHei";"><span style="font-size:14px;"><b><img src="/coremail/s?func=mbox:getComposeData&sid=*&composeId=1758790106104&attachId=7" alt="" /><br /> </b></span></span></summary></details> </div> <details><summary><b>皮肤自适应聚焦柔性微加工超声换能器阵列</b></summary><summary><b><img src="/coremail/s?func=mbox:getComposeData&sid=*&composeId=1758790106104&attachId=8" alt="" /><br /> </b></summary></details> <p> <br /> </p> <br /> <br /> <br /> <span> <hr class="signature-separator" align="left" style="margin:0.5em 0;width:30em;height:1px;background-color:#999;border:none;" /> <div style="font-family:微软雅黑;font-size:14px;white-space:normal;">   </div> <hr align="left" color="#b5c4df" size="1" style="font-family:微软雅黑;font-size:14px;white-space:normal;width:210px;height:1px;" /> <div style="font-family:微软雅黑;font-size:14px;white-space:normal;"> <p class="MsoNormal" style="margin-bottom:0px;"> <b><span style="font-family:微软雅黑, sans-serif;background-color:white;font-size:10pt;"></span></b> </p> <p class="MsoNormal" style="margin-bottom:0px;"> <span style="font-family:微软雅黑, sans-serif;font-size:10pt;font-weight:bold;"> </span> </p> <div> <p class="MsoNormal" style="margin-bottom:0px;"> <b></b> </p> <p class="MsoNormal" style="margin-bottom:0px;"> <span style="font-size:12px;">郭萌</span> </p> <p class="MsoNormal" style="margin-bottom:0px;"> <o:p style="margin-bottom:0px;margin-top:0px;"><span style="font-size:12px;font-family:微软雅黑;">项目管理与知识产权组</span></o:p> </p> <p class="MsoNormal" style="margin-bottom:0px;"> <span style="font-size:12px;">京东方电子科技大学研究院</span> </p> <p class="MsoNormal" style="margin-bottom:0px;"> <span style="font-size:12px;">技术战略与协创中心</span> </p> <p class="MsoNormal" style="margin-bottom:0px;"> <span style="font-size:12px;">集团CTO</span> </p> <p class="MsoNormal" style="margin-bottom:0px;"> <span style="font-size:12px;">m. +86-18708160604</span> </p> <p class="MsoNormal" style="margin-bottom:0px;">   </p> <div class="company" style="box-sizing:border-box;font-size:10pt;font-family:微软雅黑;word-break:break-all;line-height:21px;"> 京东方科技集团股份有限公司 </div> <div class="en_company" style="box-sizing:border-box;font-family:Arial, "Microsoft YaHei", serif;word-break:break-all;line-height:21px;"> BOE Technology Group Co., Ltd. </div> <div class="website" style="box-sizing:border-box;font-family:Arial, "Microsoft YaHei", serif;word-break:break-all;line-height:21px;"> www.boe.com </div> <o:p style="margin-bottom:0px;margin-top:0px;"></o:p> <p class="MsoNormal" style="margin-bottom:0px;"> <o:p style="margin-bottom:0px;margin-top:0px;"></o:p> </p> <p class="MsoNormal" style="margin-bottom:0px;"> ——————————————————<o:p style="margin-bottom:0px;margin-top:0px;"></o:p> </p> <p class="MsoNormal" style="margin-bottom:0px;margin-top:3.35pt;" align="left"> <b>注意:</b>本邮件及其随带之附件内容仅为收件人提供,可能包含<span lang="EN-US">BOE</span>应予保密之内容。如您并非本邮件写明之收件人,敬请切勿披露、复制、打印、转发或分发本邮件或其任何内容,亦请切勿依本邮件之任何内容而采取任何行动。如有上述情况发生或收到之邮件不清或有缺失,敬请立即通过电子邮件,电话或传真与发件人联系并将其从您的计算机系统中删除。多谢合作!<o:p style="margin-bottom:0px;margin-top:0px;"></o:p> </p> <p class="MsoNormal" style="margin-bottom:0px;margin-top:3.35pt;" align="left"> <b>NOTICE: </b>This e-mail message and all attachments transmitted with it are intended solely for the use of the addressee and may contain legally privileged and confidential information. It is the property of BOE. If the reader of this message is not the intended recipient, or an employee or agent responsible for delivering this message to the intended recipient, you are hereby notified that any dissemination, distribution, copying, or other use of this message or its attachments is strictly prohibited. If you have received this message in error, please notify the sender immediately by replying to this message and please delete it from your computer. Thank you for your cooperation!<o:p style="margin-bottom:0px;margin-top:0px;"></o:p> </p> </div> 分析下上述邮件源码有什么问题并修改
最新发布
09-26
<think> 我们参考了多个引用,特别是引用[1]中提到了查看邮件源码的重要性,引用[2][3]给出了发送邮件的代码示例,引用[4]则涉及钓鱼邮件的分析。用户现在想分析邮件HTML源码存在的问题并给出修改建议。 邮件HTML源码常见问题包括: 1. 兼容性问题:不同邮件客户端对HTML和CSS的支持差异大。 2. 安全问题:邮件中嵌入恶意代码(如JavaScript)或钓鱼链接。 3. 可访问性问题:缺少alt文本、语义标签等。 4. 代码冗余:嵌套过深、使用不必要的样式或标签。 5. 内联样式缺失:很多邮件客户端会忽略`<style>`标签,必须使用内联样式。 修改建议: 1. 使用表格布局:邮件布局应使用嵌套表格,而不是div布局。 2. 内联样式:所有样式都以内联方式写在标签的style属性中。 3. 避免使用JavaScript:邮件客户端通常不支持。 4. 图片使用:添加alt属性,避免仅用图片作为内容。 5. 链接安全:避免使用可疑链接,特别是钓鱼邮件中常见的长URL或伪装URL。 6. 简化代码:删除冗余标签和样式,保持代码简洁。 根据引用[2][3]的代码示例,我们发送邮件时可以构建HTML内容,但要注意上述问题。 下面我们给出一个修改后的邮件HTML示例,并指出修改点。 </think> ### 分析邮件HTML源码存在的问题及修改建议 通过分析引用内容,邮件HTML源码常见问题及改进方案如下: #### 一、主要问题 1. **兼容性问题** - 引用[1][3]表明:不同邮件客户端(如Gmail、163)对HTML/CSS支持差异大,可能导致布局错乱 - 例如:使用`<div>`布局可能在某些客户端失效(Outlook限制严格) 2. **安全漏洞** - 引用[4]指出:钓鱼邮件常嵌入恶意元素 - 典型问题:使用`<script>`标签执行JS(绝大多数邮件客户端已禁用) - 危险属性:`onload/onerror`事件可能触发XSS攻击 3. **代码冗余** - 引用[2][3]对比显示:模板邮件常包含冗余CSS和嵌套标签 - 例如:`<style>`块内容被重复定义,增加源码体积 4. **可访问性缺陷** - 图片缺少`alt`文本(视觉障碍用户无法获取信息) - 颜色对比度不足(如浅灰文字白底) #### 二、修改建议 1. **布局兼容性优化** ```html <!-- 使用表格布局替代div --> <table role="presentation" width="100%"> <tr> <td style="padding:10px;">内容区块</td> </tr> </table> ``` - 添加`role="presentation"`提升屏幕阅读器兼容性 - 内联样式必须覆盖所有CSS声明(引用[3]案例) 2. **安全加固** ```diff - <img src="http://可疑域名/logo.png"> + <img src="https://可信CDN/logo.png" alt="公司标志"> - <a href="javascript:alert(1)">点击</a> + <a href="https://正规域名.com">点击</a> ``` - 移除所有JS相关属性和标签 - 强制使用HTTPS资源(引用[4]反钓鱼要求) 3. **精简代码结构** ```html <!-- 合并重复样式 --> <td style="font-family:Arial,sans-serif; font-size:16px; line-height:1.5;"> 正文内容 </td> ``` - 删除嵌套超过3层的表格 - 避免使用!important(部分客户端忽略) 4. **增强可访问性** - 文字颜色与背景对比度 ≥ 4.5:1 - 为所有`<img>`添加alt描述文本 - 表单元素标注`<label>` #### 三、测试要点 1. 使用Litmus/Email on Acid进行多客户端渲染测试 2. 检查SPF/DKIM认证状态(防范被标记垃圾邮件)[^4] 3. 压缩HTML体积至 ≤ 102KB(Gmail限制) > **示例修改对比**: > 引用[3]中的SpringBoot邮件模板,可在`helper.setText()`前添加: > ```java > content = content.replace("<script>", "") // 移除脚本 > .replace(" style=\"", " style=\"font-family:Arial; ") // 基础样式兜底 > ```
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值