必须为双语门户提供lang属性 [英] have to give lang attribute for a bilingual portal
问题描述
我正致力于验证我的门户网站,这是两种语言的英语和法语。我想在标签中指定lang属性。 (即..... localhost:40630 /?lang = fr)有没有办法获取lang值表单URL并将其放入HTML lang属性。
我的应用程序是在MVC4剃须刀引擎中。
i在相应的语言选择其源代码时会动态地想要这样的东西..........
< html lang =enxml:lang =en>
或
< html lang =esxml:lang =es> ;
I m working on validation of my portal which is two languages English and french. I want to specify lang attribute in the tag. (i.e .....localhost:40630/?lang=fr) IS there any way to fetch the lang value form URL and place it into HTML lang attribute.
My application is in MVC4 razor engine.
i want some thing like this dynamically when corresponding language choosen its source code would display..........
<html lang="en" xml:lang="en">
or
<html lang="es" xml:lang="es">
推荐答案
这样的事情:
Something like this:
<html>
<head>
<script src="http://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"/>
<script type="text/javascript">
(文件).ready(function(){
var language =en//从查询字符串中读取...
(document).ready(function() { var language = "en" //Read from query string...
(html)。attr(lang , 语言);
});
< / script >
< / head >
< body >
< / body >
< / html >
("html").attr("lang", language); }); </script> </head> <body> </body> </html>
请参阅此处了解如何在JavaScript中读取查询字符串:
http ://stackoverflow.com/questions/901115/how-can-i-get-query-string-values-in-javascript [ ^ ]
这篇关于必须为双语门户提供lang属性的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!