Instead of calling raw javascript function on body load,use JQuery javascript library to achieve this.Include JQuery library from www.jquery.com.Now perform your stuffs inside load function as below.
var location=Your_fetched_location;
$(window).load(function(){
if(location== "A")
{
$("id_for_table_1").show();
}
else
{
$("id_for_table_2").show();
}
});
Hope this will resolve your problem.