Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is it possible to update the addressbar without a server round-trip?

I have a treeview inplemented in CSS, when a user clicks a folder on the treeview I'd like to update the URL in the address bar without causing a server round-trip.

The HTML looks a little like this:-

<ol>
    <li>
        <a href="www.example.com/blah?id=12345">Folder</a>
        <ol>
            <li>Child</li>
        </ol
    </li>
<ol>

The CSS I have handles the expanding of the folder but I'd like the Address bar URL to update so I can deep link to a particular folder but there is no need from a code perspective to do a round-trip to the server Is there any way of achiveing this? I have a feeling this might be impossible because of potention phishing??

I'm using HTML5, CSS2/3, jquery and ASP.NET MVC3

like image 435
David Hayes Avatar asked Jan 18 '23 23:01

David Hayes


1 Answers

HTML5 adds a History API, which allows you to use history.pushState() in modern browsers to update the URL. You are restricted to the same domain for security reasons.

This won't be supported in IE until IE10. Firefox, Safari, Opera and Chrome have all implemented it.

like image 170
ceejayoz Avatar answered Jan 30 '23 01:01

ceejayoz