prevent default behavior not working
<p>I am trying to prevent the default action for a dynamic image gallery without a JavaScript library like jQuery. Here is the project - <a href="http://the-session.co.uk/JSgallery/" rel="nofollow">http://the-session.co.uk/JSgallery/</a> It seems the links are still taking the user to the destination of the link when I do not want them too. I have am using the inline event handler <code>onclick</code> in my HTML markup to invoke the function.</p>

<pre><code>&lt;a href="images/tuco.jpg" onclick="showPic(this)" title="Tuco"&gt;Tuco Salamanca&lt;/a&gt;
</code></pre>

<p>The function:</p>

<pre><code>function showPic(whichpic) { 

    var source = whichpic.getAttribute("href");  
    var placeholder = document.getElementById("placeholder"); 
    placeholder.setAttribute("src",source); 

    var event = window.event;
    if(event.preventDefault) {
        event.preventDefault(); // handles most browsers
    }
    else {
        return false;          // handles ie
    }
}
</code></pre>

<p>This error is displayed for a split second in the console when the mouse is clicked:</p>

<p><img src="http://i.stack.imgur.com/FgWJk.jpg" alt="enter image description here"></p>

<p>Now surely event has been defined on the line above: <code>var event = window.event;</code> Any suggestions to resolve the problem?</p>
