HighDots Forums  

embedding javascript inside javascript

JavaScript discussion (multi-lingual) JavaScript discussion (alt.comp.lang.javascript)


Discuss embedding javascript inside javascript in the JavaScript discussion (multi-lingual) forum.



Reply
 
Thread Tools Display Modes
  #1  
Old   
Henry Vermeulen
 
Posts: n/a

Default embedding javascript inside javascript - 12-10-2008 , 06:22 PM






Hi.
I have a javascript function that uses text with for instance another
javascript function in it.
so what i have in short is something like this:
<?
$text='Lot of text here....<javascript type="text/javascript"
language="javascript">alert('bla');</script>... and here';
?>
<javascript type="text/javascript" language="javascript">
alert('<?=$text?>');
</script>

So this breaks.
escape() won't work.
Is there some sort of CDATA tag i can use for this?

Thanx for any advice
Henry Vermeulen
** Posted from http://www.teranews.com **

Reply With Quote
  #2  
Old   
Andy
 
Posts: n/a

Default Re: embedding javascript inside javascript - 12-11-2008 , 05:31 AM







"Henry Vermeulen" <henry (AT) devit (DOT) nl> wrote

Quote:
Hi.
I have a javascript function that uses text with for instance another
javascript function in it.
so what i have in short is something like this:
?
$text='Lot of text here....<javascript type="text/javascript"
language="javascript">alert('bla');</script>... and here';
?
javascript type="text/javascript" language="javascript"
alert('<?=$text?>');
/script

So this breaks.
escape() won't work.
Is there some sort of CDATA tag i can use for this?

Thanx for any advice
Henry Vermeulen
** Posted from http://www.teranews.com **
Hi Henry,

Untested...

<?php
$text='Lot of text here....<javascript type="text/javascript"
language="javascript">alert(\'bla\');</script>... and here';
?>

<javascript type="text/javascript" language="javascript">
alert('<?php echo urlencode($text);?>');
</script>

Fingers crossed

Andy



Reply With Quote
Reply




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Powered by vBulletin Version 3.5.4
Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.