Sunday, 29 September 2013

Document.write errors because of line break?

Document.write errors because of line break?

<?php
if ( is_home() ) {
?>
<script type="text/javascript">
if ($(window).width() < 768) {
document.write("<?php echo
do_shortcode("[mobile-slider]"); ?>");
} else {
document.write("<?php echo
do_shortcode("[desktop-slider]"); ?>");
}
</script>
My homepage renders and displays "); } else { document.write(" then the
homepage slider and then "); }. Any idea why?
JS error
SyntaxError: unterminated string literal
document.write("
HTML Output - Seems to be adding a line break which I think is breaking
the script?
<script type="text/javascript">
if ($(window).width() < 768) {
document.write("
<!--slider-->
How can I get this to still run even though there is a line break after
the document.write(" opening?

No comments:

Post a Comment