Jump to content
  • Checkout
  • Login
  • Get in touch

osCommerce

The e-commerce.

Putting JavaScript in a box?


Recommended Posts

Posted

I have a translator script that I wanted to use on the site, but I was wondering, since Javascript contains single quotes, and that tends to preak things in the boxes, is it possible to put JavaScript code into a box? This would also be good to know in the event that I want to add any other JavaScript to the store.

Thanks

DELETE MY ACCOUNT NOW

Posted

Itried creating a new box like so:

<?php
/*
 $Id: information.php,v 1.6 2003/02/10 22:31:00 hpdl Exp $

 osCommerce, Open Source E-Commerce Solutions
 http://www.oscommerce.com

 Copyright (c) 2003 osCommerce

 Released under the GNU General Public License
*/
?>
<!-- information //-->
	  <tr>
		<td>
<?php
 $info_box_contents = array();
 $info_box_contents[] = array('text' => BOX_HEADING_TRANSLATE);

 new infoBoxHeading($info_box_contents, false, false);

 $info_box_contents = array();
 $info_box_contents[] = array('script' => '<script Language="JavaScript"> <!--
document.write('<script src="http://bluedragoncreations.com/catalog/translator/translate.js"><\/script>');
//-->
</script>');

 new infoBox($info_box_contents);
?>
		</td>
	  </tr>
<!-- information_eof //-->

but that creates a parse error, and the rest of the page won't load. I tried the same, but with a \ before each ' in the script like so:

<?php
/*
 $Id: information.php,v 1.6 2003/02/10 22:31:00 hpdl Exp $

 osCommerce, Open Source E-Commerce Solutions
 http://www.oscommerce.com

 Copyright (c) 2003 osCommerce

 Released under the GNU General Public License
*/
?>
<!-- information //-->
	  <tr>
		<td>
<?php
 $info_box_contents = array();
 $info_box_contents[] = array('text' => BOX_HEADING_TRANSLATE);

 new infoBoxHeading($info_box_contents, false, false);

 $info_box_contents = array();
 $info_box_contents[] = array('script' => '<script Language="JavaScript"> <!--
document.write(\'<script src="http://bluedragoncreations.com/catalog/translator/translate.js"><\/script>\');
//-->
</script>');

 new infoBox($info_box_contents);
?>
		</td>
	  </tr>
<!-- information_eof //-->

that made the box show and the page load, but the box was empty. What am I doing wrong?

DELETE MY ACCOUNT NOW

Archived

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

×
×
  • Create New...