PDA

View Full Version : Open javascript link in same window



weezle
02-07-2009, 03:47 PM
Hi!

I'm a complete newbie and I need some help.

I have this piece of code which is opening link in new window:


<script type="text/javascript">//<![CDATA[
document.write('<a href="javascript:void window.open(\'<?php echo $product_flypage ?>\');">');
document.write( '<?php echo ps_product::image_tag( $product_thumb_image, 'class="browseProductImage" target="_self" border="0" title="'.$product_name.'" alt="'.$product_name .'"' ) ?></a>' );
//]]>
</script>

How to change this code so link would open in the same window?
Probably I should change this part: javascript:void window.open

Thanks for your help!

jscheuer1
02-07-2009, 04:23 PM
<script type="text/javascript">//<![CDATA[
document.write('<a href="<?php echo $product_flypage ?>" target="_self">');
document.write( '<?php echo ps_product::image_tag( $product_thumb_image, 'class="browseProductImage" border="0" title="'.$product_name.'" alt="'.$product_name .'"' ) ?></a>' );
//]]>
</script>

But, at that point, no javascript is required:


<a href="<?php echo $product_flypage ?>" target="_self">
<?php echo ps_product::image_tag( $product_thumb_image, 'class="browseProductImage" border="0" title="'.$product_name.'" alt="'.$product_name .'"' ) ?></a>

should do just fine.

weezle
02-07-2009, 05:12 PM
Of course!

In fact that code was modified, javascript was used to display image with slimbox effect, but I changed it to link.

Thanks, it works!