pushkinpassey
12-10-2009, 03:29 PM
Hi!
I am trying to use innerHTML but unsuccessfully on my Wordpress website.
Please see the following code:
var string = "<?php the_content(); ?>";
function textchange() {
document.getElementById('box_content_slideshow').innerHTML = '<div class="box_content">'+string+'</div>';
}
The problem is that when wordpress puts the content in the variable 'string', it automatically adds carriage returns/line break result in:
var string = "<p>heading</p>
<p>sample text</p>
<p>more text</p>";
Is there any way I can remove the line breaks making the string like:
var string = "<p>heading</p><p>sample text</p><p>more text</p>";
I have tried using:
var string = (<r><![CDATA[
The text string goes here. Since this is a XML CDATA section,
stuff like <> work fine too, even if definitely invalid XML.
]]></r>).toString();
But this only works in FF, and not in IE, Opera, or Safari.
Thanks a lot!
Cheers!
I am trying to use innerHTML but unsuccessfully on my Wordpress website.
Please see the following code:
var string = "<?php the_content(); ?>";
function textchange() {
document.getElementById('box_content_slideshow').innerHTML = '<div class="box_content">'+string+'</div>';
}
The problem is that when wordpress puts the content in the variable 'string', it automatically adds carriage returns/line break result in:
var string = "<p>heading</p>
<p>sample text</p>
<p>more text</p>";
Is there any way I can remove the line breaks making the string like:
var string = "<p>heading</p><p>sample text</p><p>more text</p>";
I have tried using:
var string = (<r><![CDATA[
The text string goes here. Since this is a XML CDATA section,
stuff like <> work fine too, even if definitely invalid XML.
]]></r>).toString();
But this only works in FF, and not in IE, Opera, or Safari.
Thanks a lot!
Cheers!