开发者

Is it possible to ignore code to improve loading time?

I dislike having to load a new page each time I clic开发者_StackOverflow社区k a link, I'm thinking of building something similar to iframe.

When i click an anchor tag I want to load a div, but I don't want that div content to be loaded before I click that anchor tag.


I.e. you go to www.example.com, it loads pretty quick, then you click ‘bio’ or ‘contact us’ and it loads up new content that's already written, kind of telling the browser to ignore parts of the code in the HTML. Is this even possible?


In jQuery you can type:

<script type="text/javascript">
        $(document).ready(function(){
        $("#DivName a").click(function(event){
            event.preventDefault();
            $("#DivName").load($(this).attr("href"));
        });
    });
    </script>

it will work ;)


I use a product called Google Web Toolkit to do exactly that. With GWT you will typically change parts of the UI without requesting an entirely new HTML page from the server. You can send requests for data from the server and JavaScript code running in the browser is responsible for displaying that data to the user. GWT applications are written with Java and compiled into JavaScript for execution on the browser. No plugins or extensions are required for your user to run your application, just a modern browser.

JQuery is another option. GWT tends to appeal to Java developers because it is written in the Java language, while JQuery is a set of JavaScript libraries that many JavaScript developers are more comfortable with.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜