Hey guys this is kind of a JavaScript question but the script works elsewhere so I have a feeling it's got something to do with the fact it's being echoed by php. Can anyone tell me why this isn't working:

if (($_SESSION['count'] % 5 == 0) && ($_SESSION['countView'])) { 
          echo 
'<a href="index.php?act=generate_quotes&amp;beginCount&amp;cb=%3C?php%20echo%20time();?%3E" id="logo"  onClick="myinfo"(); return false"></a>';

And the function:

<script type="text/javascript">
<!--
function myinfo() {
window.open( "http://www.google.com/" )
}
//-->
</script>

The href link works fine. But I'm trying to get it to open a info window at the same time. Any reason this isn't working?

Thanks for any help.

Fixed

echo '<a href="index.php?act=generate_quotes&amp;beginCount&amp;cb='.time().'" id="xavisys-logo" onClick="myinfo(); return false;"></a>';

Fixed

echo '<a href="index.php?act=generate_quotes&amp;beginCount&amp;cb='.time().'" id="xavisys-logo" onClick="myinfo(); return false;"></a>';

And interaction between server side language like PHP and client side language like JS is best done via AJAX

Member Avatar for diafol

Urgh - spawning a javascript open window - popup blockers can preventing this. I really would suggest that you avoid this method.

Urgh - spawning a javascript open window - popup blockers can preventing this. I really would suggest that you avoid this method.

And best way is to learn AJAX

Urgh - spawning a javascript open window - popup blockers can preventing this. I really would suggest that you avoid this method.

Don't get me wrong I'm not trying to use this for advertising. It just seemed the best method I could find for what I wanted to achieve. Would you mind suggesting a more appropriate method?

Member Avatar for diafol

What is it exactly are you trying to achieve?

I would suggest a lightbox - there are literally hundreds out there. jQuery has a few nice ones.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.