I have my page so far: einserpasch.com
The crucial markup is this:
<ul>
<li><a href="#content_01" id="content_01"> !?! </a></li>
</ul>
And the div-container at the end of the document:
<div id="haupt_iframe">
</div>
On clicking on the drop down menu items the jQuery function loads content from a HTML file into the div container (I omitted the fading in the code below) while the URL in my browser gains the #-tag ending (like einserpasch.com/#content_01):
$(document).ready(function(){
$("li a").click(function(){
var knopf = $(this).attr('id');
$("#haupt_iframe").load("bilder/"+knopf+".html");
});
So far no problem.
but now I want a direct link to the different galleries. To make the images show in the div container only by typing in the correct URL including the #-sign.
the idea was that having an hash sign in the URL would make me get an id selector when i read it with window.location.hash.
I tried to manage it like this:
$(document).ready(function(){
if(window.location.hash){
$(window.location.hash).trigger(function(){
var knopf = $(this).attr('id');
$("#haupt_iframe").load("bilder/"+knopf+".html");
});
};
});
But so far, only the click on the a attribute fires the function but not typing in the URL with the specific #-tag at the end. like einserpasch.com/#painting.
So what am I missing to make me have a direct link?
Thanks in advance!
clemens :)
ps.: yes, i posted this in code review because i wanted you to review my code. but as a part of my code doesn't work the post was closed. i'm still learning the rules of this community...