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!

Recommended Answers

All 2 Replies

Rather than using the window.open() function, use the URL passed in the function as the value of the HREF attribute of the ANCHOR element.

document.write('<a href="<?php echo $product_flypage ?>">');

assuming that the echo part writes out the URL.

Use this code:

<script type="text/javascript">//<![CDATA[
document.write('<a href="<?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>
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.