I'm using jQuery to load pages into a div - instead of using iframes. However, I have an issue where I cannot display a page when someone visits the URL.
So on page load, the canvas is empty (next to the menu) until the visitor clicks a link.
What I want to show is page-a.html whenever the page is visited - so the page doesn't look so empty.
Does anyone have any ideas?
<script>
$('[data-target]').click( function (e) {
$.get($(this).attr('href'), function(data){
$('#halloffame').empty();
$(data).find(".partner_body").appendTo("#halloffame");
});
e.preventDefault(); // prevent anchor from changing window.location
});
</script>
So I managed to resolve this by using @Roberto's suggestion and my original code (Simply added load onto the end)
Here is the finished code, which loads a URL on page load (and still allows you to open links in a div)
$('[data-target]').click( function (e) {
$.get($(this).attr('href'), function(data){
$('#halloffame').empty();
$(data).find(".partner_body").appendTo("#halloffame");
});
e.preventDefault(); // prevent anchor from changing window.location
});
$.get( "pages/accounting-software/", function( data ) {
$('#halloffame').empty();
$(data).find(".partner_body").appendTo("#halloffame");
});
Hope this helps anyone else trying to achieve the same result.