admin管理员组文章数量:1307665
What is the best way to make a HTML fallback via Angular?
I need something like this:
<span>{{angularText}} plain text</span>
The plain text would be a "backup" (perhaps generated by the server), in case the user doesn't have JavaScript enabled. Of course, if the user has JavaScript enabled, then I obviously don't want both to show.
What is the best way to make a HTML fallback via Angular?
I need something like this:
<span>{{angularText}} plain text</span>
The plain text would be a "backup" (perhaps generated by the server), in case the user doesn't have JavaScript enabled. Of course, if the user has JavaScript enabled, then I obviously don't want both to show.
Share Improve this question edited May 13, 2014 at 22:12 inf3rno 26.2k13 gold badges121 silver badges206 bronze badges asked May 13, 2014 at 21:34 user3634330user3634330 431 silver badge2 bronze badges 6- 2 To be honest, if you're using Angular, you're probably already making the assumption that the user has JS enabled. – Alexis King Commented May 13, 2014 at 21:36
- Do you genuinely have a case of users that have no ability to run Javascript? – Ishan Chatterjee Commented May 13, 2014 at 21:36
- 1 Go to a angular demo page, turn JS off and you'll see what happens. (hint: probably nothing, depending on the page. But you'll definitely see `{{foo}}`` all over the place.) – nietonfir Commented May 13, 2014 at 21:37
- Actually you won't see anything like that: angularjs It has a HTML fallback. – inf3rno Commented May 13, 2014 at 22:05
- 1 It is not so much about the ability, but the will to use JavaScript, actually. JavaScript is the base for the majority of XSS attacks. With JavaScript enabled, browser tracking bees far more powerful, also when using anonymity systems like Tor, JavaScript can be used to find your actual IP address and break your anonymity. In my oppinion, it is a good idea to offer your concerned users at least read access without requiring JavaScript. – aef Commented Feb 10, 2015 at 11:26
2 Answers
Reset to default 12<span ng-bind="angularText">Default text from server</span>
?
But like the others have mentioned, why use Angular to create an app if there's a slight chance some of the intended users have JS disabled?
I suggest adding this to your site as well:
<noscript>
You do not have JS enabled. Since this is an Angular based website, it won't do jack for you :-)
</noscript>
Inside index.html:
<noscript>
<h1>Your title</h1>
<div style="somestyles...">
Your content
</div>
</noscript>
If one wishes he/she can keep a skeleton of what the site supposed to have looked if js was enabled and then a request message inside to enable javascript .
本文标签: javascriptHow do I make a HTML fallback via AngularStack Overflow
版权声明:本文标题:javascript - How do I make a HTML fallback via Angular? - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1741830274a2399889.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论