php echo within javascript possible? -
i trying add php echo within javascript (for translation reasons). seems though cannot echo javascript?
this initial code:
else if(o.thumbplacement=='bottom'){$outer.append('<div style="padding-top:4px; text-align:center; font-family:arial, helvetica, sans-serif; font-size:11px; color: #999; "><img src="images/magnify.png" alt="enlarge" /> click , move zoom</div><ul class="thumbs">'+cont+'</ul>');}
this how edited it:
else if(o.thumbplacement=='bottom'){$outer.append('<div style="padding-top:4px; text-align:center; font-family:arial, helvetica, sans-serif; font-size:11px; color: #999; "><img src="images/magnify.png" alt="enlarge" /> <?php echo text_click_to_enlarge; ?></div><ul class="thumbs">'+cont+'</ul>');}
i tried
<?php echo "test"; ?>
returns nothing well.
is there way this?
i add more detailled answer : can generate javascript php, can generate string in php (in php file) :
<script type="text/javascript"> var mytext = <?php echo json_encode("hello world!"); ?> </script>
then can access mytext
variable in javascript code.
but cannot call php in js file, because php run on server side, , javascript (well in case) on client side.
anyway, think bad idea translate stuff this... either directly translatation in html code using php, or import "database" file containing translation current language. there tons of javascript translation libraries (i18n).
Comments
Post a Comment