Have a look on what HTML is produced:
<a class="uber-grid-hover" href="onclick=popWin('http://www.weybridgestrategies.com/team/debra-porter-president-ceo'); return (false);" >
How it should look like:
<a class="uber-grid-hover" href="http://www.weybridgestrategies.com/team/debra-porter-president-ceo"
onclick="popWin('http://www.weybridgestrategies.com/team/debra-porter-president-ceo'); return false;">
So your popWin function is already ok, but you need to justify the anchor's attributes href
and onclick
. onclick
is javaScript, so you don't need the javaScript prefix, and also you don't need inline onclick=
because this creates a global variable. The return false
will prevent the browser to follow the href, if javascript is available. By using this.href
this is will not do what you expect at least in IE, because this is in IE the event, not the anchor.
EDIT: Actually your TestLink does what you intended, as of Firefox Aurora v24, without blocking-a-popup.
But I have to follow Brian's comment, that your new window may be considered a popup, so it would be the best if you do window.open(url, '_blank')
or simply use <a target="_blank" href="...">
- and looking for a javaScript "popup" that doesn't load a new page, but looks more HTML5ish, for example using jQuery UI or by trying your own jS (and that would be another answer to a much bigger question... ;))
UPDATE: A good idea unleashing your jQuery already included, lets speak javaScript:
<script type="text/javascript">
function popWin(url)
{
var thePopCode = window.open(url,'','height=800, width=1000, top=500, left=200,scrollable=yes, menubar=yes, resizable=yes');
if (window.focus) {
thePopCode.focus();
}
}
jQuery(document).ready(function ($) {
// here is your HTML DOM ready
// create an onclick event for every a.uber-grid-hover
$("a.uber-grid-hover").click(function (event) {
event.preventDefault(); // this is "like" return false
// this get's the href from your anchor, using jQuery sugar
var url = $(this).attr("href");
// call your fun
popWin(url);
});
});
</script>
Using this script, you should no more need to create onclick
attributes for every single anchor. Simply put that into your wordpress source, this should work as is.
Now simply make the <a>
using class="uber-grid-hover"
, this is required so that jQuery can select the hovers easily, then you need the href
and you may include also target="_blank"
so that non-javascript users will also have the page in a new window.
<a class="uber-grid-hover" target="_blank"
href="http://www.weybridgestrategies.com/team/debra-porter-president-ceo">