Last Updated: February 25, 2016
·
532
· michalkow

HTML prototyping

Sometimes I like to do a site prototype in pure HTML, especially when I am not sure what type of language of framework I will use for the project.
I don't want to use any big templating system, instead I use this simple (jQuery) trick:

$('body').on('click', 'a', function(e) {
    e.preventDefault();
    $('#content').load($(this).attr('href'));
});

Script will just load html into my #content div from html files.
Two thing to be aware of though:

  • every <a> link will be affected, you can change it to custom class if you use <a> tags for other things.

  • some browsers might have problem loading local files like that, due to same-origin policy.

Have a fresh tip? Share with Coderwall community!

Post
Post a tip
Did you know?

JavaScript on a page runs with the privileges of that origin. One altered library, tag manager, or snippet can read inputs, change what people see, and call your APIs as the user.

Security insights from Cside