Jump to content
  • Checkout
  • Login
  • Get in touch

osCommerce

The e-commerce.

Odd javascript/saved file problem


consafos

Recommended Posts

Hello, I've been struggling with this one for quite a while.. I haven't got any closer to working out what's wrong so any ideas or suggestions would be appreciated. In my product_info.php page I have the following code to display the product image (on roughly line 100):

 

<script language="javascript"><!--

document.write('<?php echo '<a href="javascript:popupWindow('' . tep_href_link(FILENAME_POPUP_IMAGE, 'pID=' . $product_info['products_id']) . '')">' . tep_image(DIR_WS_IMAGES . $product_info['products_image'], addslashes($product_info['products_name']), SMALL_IMAGE_WIDTH, SMALL_IMAGE_HEIGHT, 'hspace="5" vspace="5"') . '<br>' . TEXT_CLICK_TO_ENLARGE . '</a>'; ?>');

//--></script>

 

which is fine. However, when this page is displayed no image shows up. When viewing the source of the displayed product_info.php I get the following code:

 

<script language="javascript"><!--

document.write('



<a href="javascript:popupWindow('http://www.mywebsite.com/popup_image.php?pID=35')"><img src="images/my_image.jpg" border="0" alt="My Image" title="My Image" width="100" height="91" hspace="5" vspace="5"><br>Click to enlarge</a>');

//--></script>

 

The problem is the space that appears after document.write(' which is causing a javascript error which in turn is stopping the image from showing.. any ideas?

Link to comment
Share on other sites

Ok, I think I've fixed the problem. After a lot of trial and error I've removed the javascript and ended up with

<?php echo '<a href="javascript:popupWindow('' . tep_href_link(FILENAME_POPUP_IMAGE, 'pID=' . $product_info['products_id']) . '')">' . tep_image(DIR_WS_IMAGES . $product_info['products_image'], addslashes($product_info['products_name']), SMALL_IMAGE_WIDTH, SMALL_IMAGE_HEIGHT, 'hspace="5" vspace="5"') . '<br>' . TEXT_CLICK_TO_ENLARGE . '</a>'; ?>

which works. The next few lines after that is a <noscript> section for displaying the image for people that don't have javascript. Does this mean that anyone without javascript enabled will see the image twice? How do I disable javascript (I'm using internet explorer and opera at the moment) so I can test this? Is there a better way of doing what I've done?

 

Thanks.

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...