你如何在网址中解码html? [英] How do you decode html in a url?

查看:75
本文介绍了你如何在网址中解码html?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在我的项目中,我有一个后退按钮,它调用一个javaScript函数,在调用时记住上一个url。

In my project I have got a "back button" that is calling a javaScript function that remembers the previous url when called.

//back button function
function goBack() { $window.history.back(); }



单击后退按钮时记住或被调用的URL包含ID,这是ID用于过滤数据。我遇到的主要问题是这个ID是以html编码的字符串形式返回的。例如,这是被调用的网址:



//查询?$ filter = VehicleId%20eq%20%272415%27&



正如您所见,上面的网址中的VehicleId为2415,也被编码为%20%272415%27&。这在纯文本中是VehicleId =2415。这与我的程序冲突,因为我的程序期望一个int变量而不是一个字符串。



为了解决这个问题,我试图去编码?从html到使ID成为一个int。我一直在看这个http://www.w3schools.com/jsref/tryit.asp?filename=tryjsref_unescape,但我仍然无法想象如何把它放在我的项目中。





我使用$ location来记住网址中的ID,如下所示:




the url being remembered or being called when the back button is clicked contains an ID and this is ID is used to filter data. The main problem i'm having is that this ID is being returned as a string encoded in html. for example this is the url being called:

//Lookups?$filter=VehicleId%20eq%20%272415%27&

As you can see VehicleId is 2415 in above url, which is also encoded to %20%272415%27&. this in plain text is VehicleId = "2415". This is clashing with my program as my program is expecting an int variable instead of a string.

To resolve this i am trying to de -encode?? from html to make the ID to an int. and i having been looking at this http://www.w3schools.com/jsref/tryit.asp?filename=tryjsref_unescape but i still can't figure how to put this in my project.


I am using $location in order to remember the ID in url like so:

if ($location.search().vehicle) {
                           var str = vehicle;
                           var strEsc = unescape(str);
                           vehicle = strEsc;

                         vehicle = $location.search().vehicle;

                       }



老实说,如果我这样做,我不会这样做(我不确定)。请问任何人帮忙吗?


To be honest i don't if i am doing this right (which i'm not sure) ..Is any one to help with this please?

推荐答案

window。 history .back(); }
window.history.back(); }



单击后退按钮时记住或被调用的URL包含ID,这是ID用于过滤数据。我遇到的主要问题是这个ID是以html编码的字符串形式返回的。例如,这是被调用的URL:



//查找?


the url being remembered or being called when the back button is clicked contains an ID and this is ID is used to filter data. The main problem i'm having is that this ID is being returned as a string encoded in html. for example this is the url being called:

//Lookups?


filter = VehicleId%20eq%20%272415% 27安培;



正如您所见,上面的网址中的VehicleId为2415,也被编码为%20%272415%27&。这在纯文本中是VehicleId =2415。这与我的程序冲突,因为我的程序期望一个int变量而不是一个字符串。



为了解决这个问题,我试图去编码?从html到使ID成为一个int。我一直在看这个http://www.w3schools.com/jsref/tryit.asp?filename=tryjsref_unescape,但我仍然无法想象如何把它放在我的项目中。





我正在使用
filter=VehicleId%20eq%20%272415%27&

As you can see VehicleId is 2415 in above url, which is also encoded to %20%272415%27&. this in plain text is VehicleId = "2415". This is clashing with my program as my program is expecting an int variable instead of a string.

To resolve this i am trying to de -encode?? from html to make the ID to an int. and i having been looking at this http://www.w3schools.com/jsref/tryit.asp?filename=tryjsref_unescape but i still can't figure how to put this in my project.


I am using


位置以便记住url中的ID,如下所示:



location in order to remember the ID in url like so:

if (


这篇关于你如何在网址中解码html?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆