javascript – noscript标签,如果没有启用,我需要提供替代的HTML
内容导读
互联网集市收集整理的这篇技术教程文章主要介绍了javascript – noscript标签,如果没有启用,我需要提供替代的HTML,小编现在分享给大家,供广大互联网技能从业者学习和参考。文章包含4186字,纯文字阅读大概需要6分钟。
内容图文
![javascript – noscript标签,如果没有启用,我需要提供替代的HTML](/upload/InfoBanner/zyjiaocheng/747/8e6b8f6629614ec4a5a36515ebae7dea.jpg)
如果在用户的浏览器上没有启用JavaScript,是否可以用HTML替换javascript?
我知道我可以使用< noscript>这个显示代替javascript< / noscript>
这工作正常,但它仍然运行JavaScript.
理论上我会想要这个:
如果启用了javascript
运行javascript
如果未启用javascript
不要运行javascript并提供替代方法
我正在使用这个jQuery插件:http://malsup.com/jquery/cycle/int2.html
当我在safari上禁用javascript时,它会显示所有三个项目,都在div中.插件在每个项目中淡入淡出,但如果禁用它,它会连续显示所有三个,而不会像启用javascript一样淡入淡出.
禁用javascript后,我想阻止它同时显示所有三个项目.我会告诉你看起来是什么样的,以及它在JavaScript被禁用时的作用.
禁用视图:http://i42.tinypic.com/212y1j6.png(注意它们3堆叠在彼此的顶部) – 我想阻止它发生,因为JavaScript被禁用
启用视图:http://i39.tinypic.com/9gwu3d.png
以下是项目所在div的代码:
$(document).ready(function() {
$('#featured-programs-left').cycle({
fx: 'fade',
speed: 'slow',
timeout: 15000,
next: '#next2',
prev: '#prev2'
});
});
<div id="featured-programs-left">
<div>
<a href="http://site.com/academics/majors/emergency_medical_technician_-_paramedic/" title="Emergency Medical Technician - Paramedic"><img src="http://site.com/images/uploads/images/emt.jpg" alt="Emergency Medical Technician - Paramedic" /></a>
<strong>Emergency Medical Technician - Paramedic</strong>
<p>This unique A.A.S. degree program, a partnership between College and Faxton-St. Luke’s Healthcare provides the paramedic student the education necessary to function in an</p>
<p><a href="http://site.com/academics/majors/emergency_medical_technician_-_paramedic/" title="Learn more about Emergency Medical Technician - Paramedic">Learn more</a></p>
</div>
<div>
<a href="http://site.com/academics/majors/travel_tourism_hospitality_events_management/" title="Travel & Tourism: Hospitality & Events Management"><img src="http://site.com/images/uploads/images/hospitality_event_planning.jpg" alt="Travel & Tourism: Hospitality & Events Management" /></a>
<strong>Travel & Tourism: Hospitality & Events Management</strong>
<p>This program prepares students for exciting careers in the travel and tourism industry and the hospitality and events planning field. Graduates are prepared to:<br</p>
<p><a href="http://site.com/academics/majors/travel_tourism_hospitality_events_management/" title="Learn more about Travel & Tourism: Hospitality & Events Management">Learn more</a></p>
</div>
<div>
<a href="http://site.com/academics/majors/fashion_buying_merchandising/" title="Fashion Buying & Merchandising"><img src="http://site.com/images/uploads/images/fashion_merchandising.jpg" alt="Fashion Buying & Merchandising" /></a>
<strong>Fashion Buying & Merchandising</strong>
<p>This program prepares graduates for careers throughout the Fashion Industry including positions in buying, fashion merchandising, retail and wholesale sales, retail</p>
<p><a href="http://site.com/academics/majors/fashion_buying_merchandising/" title="Learn more about Fashion Buying & Merchandising">Learn more</a></p>
</div>
</div>
div的CSS
#featured-programs-left img,
#featured-programs-right img{
xfloat:left;
overflow:auto;
xclear:left;
xwidth:351px;
xpadding:0 5px 5px 0;
border:0;
}
#featured-programs-left,
#featured-programs-right {
height:625px;
float:left;
overflow:auto;
clear:left;
clear:right;
width:100%;
xborder:2px solid red;
}
#featured-programs-left div,
#featured-programs-right div {
xborder:1px solid purple;
overflow:auto;
clear:left;
clear:right;
width:352px;
height:345px;
}
#featured-programs-left {
float:left;
}
解决方法:
有点像Ates’s solution,您可以使用Javascript来更改启用它的用户的内容.例如,假设您有一个花哨的菜单,为Javascript用户提供超级简单的导航,但对非JS用户来说却毫无价值.在HTML中将display属性设置为’none’,然后使用JS启用它.在您的情况下,如果您有不希望为非JS用户显示的内容,则可以默认隐藏它.缺点是如果浏览器关闭JS和CSS,这将无法正常工作.如果您对此感到担心,可以使用JS插入内容.
<html>
<head>
<script>
$(document).ready(function() {
$('.jsok').show();
});
</script>
<style>
.jsok { display: none; }
</style>
</head>
<body>
<div class="jsok"><!-- content for JS users here--></div>
<div><!-- content for everyone here --></div>
<noscript><!-- content for non-js users here --></noscript>
</body>
</html>
内容总结
以上是互联网集市为您收集整理的javascript – noscript标签,如果没有启用,我需要提供替代的HTML全部内容,希望文章能够帮你解决javascript – noscript标签,如果没有启用,我需要提供替代的HTML所遇到的程序开发问题。 如果觉得互联网集市技术教程内容还不错,欢迎将互联网集市网站推荐给程序员好友。
内容备注
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 gblab@vip.qq.com 举报,一经查实,本站将立刻删除。
内容手机端
扫描二维码推送至手机访问。