Reputation: 12568
I have a WordPress site which I am calling a URL from a custom field using the following
<?php $redirect_url = get_post_meta($post->ID, 're_url', true);
I am also using TinyBox2 to display this URL in a popup box, using the callback function I have set it to run a function in the footer that redirects to, for now, www.google.com
TinyBox
-------
<div class="redirect" onclick="TINY.box.show({html:'Your website is : <br /><?php echo get_post_meta($post->ID, 're_url', true); ?>',animate:true,close:true,mask:false,boxid:'success',openjs:function(){openJS()}})"></li>
Footer
------
<script type="text/javascript">
function openJS(){setTimeout("top.location.href = '$redirect_url'",5000);}
</script<
This isnt working as I want it to, can anybody explain where I am going wrong?
Upvotes: 0
Views: 492
Reputation: 686
Set timeout accepts a function, not a string.
EDIT: Here's some (untested) code. This should get you going in the right direction, I hope.
function openJS(){
window.setTimeout(function(){
window.location = "<?php echo $URL ?>";
}, 5000);
}
Upvotes: 1
Reputation: 11254
You need to write php variable, so that javascript can pick it up!!
function openJS(){setTimeout("top.location.href = '<?php echo $redirect_url; ?>'",5000);}
Upvotes: 1