小编Wil*_*lic的帖子

History.js无法在Internet Explorer中运行

我试图让history.js在Internet Explorer中工作,因为我需要history.pushState()才能工作.我已经阅读了GitHub(https://github.com/browserstate/History.js/)上的说明并试图实现它,但没有取得任何成功.这就是我所拥有的

<!DOCTYPE html>
<html>
<head>
    <!-- jQuery --> 
    <script src="http://ajax.googleapis.com/ajax/libs/jquery/1.6.2/jquery.min.js"></script> 
    <!-- History.js --> 
    <script defer src="http://balupton.github.com/history.js/scripts/bundled/html4+html5/jquery.history.js"></script> 
    <script type="text/javascript">
        function addHistory(){

            // Prepare
            var History = window.History; // Note: We are using a capital H instead of a lower h

            // Change our States
            History.pushState(null, null, "mylink.html"); 
        }      
    </script>
</head>
<body>
    <a href="mylink.html">My Link</a>
    <a href="otherlink.html">Other Link</a>
    <button onclick="addHistory()" type="button">Add History</button>   
</body>
Run Code Online (Sandbox Code Playgroud)

不知道我做错了什么,但它肯定不适用于IE8或IE9.它确实可以在Firefox中运行,但这可能是因为Firefox实际上支持history.pushstate.任何帮助表示赞赏

html javascript jquery history.js pushstate

7
推荐指数
1
解决办法
3187
查看次数

将json转换为自定义对象数组

我正在尝试使用C#和Json.Net为Windows Phone 7创建一个reddit应用程序(仅用于练习).我试图把json转换成c#可以使用的东西,以及其他一些东西.我可以提取我想要的数据,但不知道我是否正在使用正确的方法.然后,一旦我有了json数据,我就无法将其转换为自定义对象.无论如何,我确信这段代码中有很多错误,所以任何帮助理顺我的标题都会非常感激.

这是代码:

   public partial class MainPage : PhoneApplicationPage
    {
        string json = "";
    RootObject topic = new RootObject();
    public MainPage()
    {
        InitializeComponent();
    }
    private void Button_Click(object sender, RoutedEventArgs e)
    {
        textBlock1.Text = "Retrieving...";
        string url = @"http://www.reddit.com/r/all.json";
        HttpWebRequest hWebRequest = (HttpWebRequest)HttpWebRequest.Create(url);
        hWebRequest.Method = "GET";
        hWebRequest.BeginGetResponse(Response_Completed, hWebRequest);
    }
    public void Response_Completed(IAsyncResult result)
    {
        HttpWebRequest request = (HttpWebRequest)result.AsyncState;
        HttpWebResponse response = (HttpWebResponse)request.EndGetResponse(result);
        using (StreamReader streamReader = new StreamReader(response.GetResponseStream()))
        {
            json = streamReader.ReadToEnd();
            topic = JsonConvert.DeserializeObject<RootObject>(json);

        }
        Deployment.Current.Dispatcher.BeginInvoke(() =>
        {
            //textBlock2.Text …
Run Code Online (Sandbox Code Playgroud)

c# json reddit windows-phone-7

3
推荐指数
1
解决办法
2809
查看次数

标签 统计

c# ×1

history.js ×1

html ×1

javascript ×1

jquery ×1

json ×1

pushstate ×1

reddit ×1

windows-phone-7 ×1