admin管理员组文章数量:1389783
The problem is that I don't get the document.location.href
in Arabic letters.
I get it as
/cat/%D9%81%D8%B9%D8%A7%D9%84%D9%8A%D8%A7%D8%AA
instead of:
/cat/فعاليات
I'm trying to get the page url and pare it to a list of menu items, so I can determine which item to select.
I'm trying this:
var url = document.location.href;
if(url.indexOf('blablabla') > 0 )
{
...
}
instead of 'blablabla' there will be some Arabic text.
Help Please! Thank you
The problem is that I don't get the document.location.href
in Arabic letters.
I get it as
/cat/%D9%81%D8%B9%D8%A7%D9%84%D9%8A%D8%A7%D8%AA
instead of:
/cat/فعاليات
I'm trying to get the page url and pare it to a list of menu items, so I can determine which item to select.
I'm trying this:
var url = document.location.href;
if(url.indexOf('blablabla') > 0 )
{
...
}
instead of 'blablabla' there will be some Arabic text.
Help Please! Thank you
Share Improve this question edited Jan 20, 2019 at 22:28 Salim Mahboubi 5798 silver badges26 bronze badges asked Jan 29, 2013 at 13:24 HasanAboShallyHasanAboShally 18.7k9 gold badges31 silver badges35 bronze badges 6- in the urls everything is by default url_encod(); your only option is to replace 'blablabla' with <?php echo url_encode('ARABIC_TEXT'); ?> I think it will do the trick – DaGhostman Dimitrov Commented Jan 29, 2013 at 13:26
- 1 Thanks for the fast replay, I'm not using php.. any other ideas ? – HasanAboShally Commented Jan 29, 2013 at 13:28
-
1
Why are you using Arabic letters to name your folders instead of latin-character transcripts? For example use
events
instead ofفعاليات
. And then your content to be in Arabic. I think even if you fix this here now, you will have more problems in the future. – Dimitris Damilos Commented Jan 29, 2013 at 13:28 - actually im using asp routing, i get all the data from the database.. i just wanted it to be easy for the users.. so they can access the links directly. – HasanAboShally Commented Jan 29, 2013 at 13:30
- Is there a public URL we can see this problem on? (It doesn't have to be the one you're working on, just one with Arabic characters in it.) – Paul D. Waite Commented Jan 29, 2013 at 13:31
2 Answers
Reset to default 5You have to use decodeURIComponent(url);
Check this fiddle: http://jsfiddle/7spmF/
You can use the decodeURIComponent it decodes a Uniform Resource Identifier (URI) ponent previously created by encodeURIComponent or by a similar routine.
本文标签: javascriptGetting documentlocationhref with Arabic lettersStack Overflow
版权声明:本文标题:javascript - Getting `document.location.href` with Arabic letters - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1744585287a2614158.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论