jQuery: Syntax error? Unexpected Token ILLEGAL when I try to make my code nice. (with returns and tabs and such)

$j('body').append("\ <style type='text/css'>\ .floatymessoge {\

webkit give me the error on the first line with the append to body. how do I fix it?

I may or may not have the css jqueried into my file later... but the I'd like to be able to format what I'm appending to the document.

Full thing:

function floatymessage(message){ if (!$j('.floatymessage')){ $j('body').append("\ <style type='text/css'>\ .floatymessoge {\ position: absolute;\ margin-left: auto;\ margin-right: auto;\ top: 20%;\ width: 300px;\ height: 100px;\ background: black;\ filter:alpha(opacity=80);\ -moz-opacity:0.8;\ -khtml-opacity: 0.8;\ opacity: 0.8;\ box-shadow: 10px 10px 5px #000;\ border: 1px solid black;\ border-bottom-left-radius: 10px 10px;\ border-bottom-right-radius: 10px 10px;\ border-top-left-radius: 10px 10px;\ border-top-right-radius: 10px 10px;\ line-height: 100px;\ z-index: 10000;\ display: none;\ }\ </style>\ <div class='floatymessage'>\ </div>"); } $j(".floatymessage").html(message) $j(".fleatymessage").css('display', 'block') }

-------------Problems Reply------------

The issue is that you have some extra white space after <div class='floatymessage'>\:

// white space here --------v
<div class='floatymessage'>\

so the newline character is not being escaped.

Off topic, but you should also note that in your <style> tag, the word message in .floatymessage is spelled with an o, as in .floatymessoge.

Add a space before the \ escape character. NOT :)

$j('body').append(" \
<style type='text/css'> \
.floatymessoge { \

Edit: Your code should work without problems. Can you provide a more complete example? I suspect the problem lies elsewhere.

Category:jquery Views:2 Time:2010-07-28
Tags: jquery

Related post

  • Javascript syntax error unexpected token illegal 2011-12-23

    function queue_instructions(){ var input_message = "Commands w? Shows whos on the waitlist w+ Adds yourself to the waitlist w- Removes yourself from the waitlist w++ Moves yourself down one spot on the waitlist -mods Shows a list of available moderat

  • jQuery syntax error - unexpected token 2011-08-09

    I'm trying to debug and I keep getting a syntax error. I'm not sure what is going on with this. I'm trying to have it where if I click on an object which is attached to "$color_cell" it pushes the atrr("id") into the black_colors array. Could someone

  • ANTLR syntax error unexpected token: + 2011-04-30

    Hi I have a small problem in my ANTLR tree grammar. I am using ANTLRWorks 1.4. In parser grammar I have the rule like this: declaration : 'variable' IDENTIFIER ( ',' IDENTIFIER)* ':' TYPE ';' -> ^('variable' IDENTIFIER TYPE)+ So I wanted one tree

  • Syntax error: unexpected token "-" 2012-01-21

    I'm doing a web application, and when I started writing the code in JavaScript I'm getting this error: Syntax error: unexpected token "-" javascript I'm using Aptana Studio 3. I thought it was Aptana's problem, so then I tried with Eclipse, but still

  • PHP/jQuery Uncaught SyntaxError: Unexpected token ILLEGAL 2011-07-27

    i have problem with between php and jQuery/Javascript...It wont show up or can't work. My Code: if($bottom_1_banner == "true"){ //$data_AD .= '$(\'.ban_bottom\').html(\''.htmlentities($bottom_banner).'\').text();'; $data_AD .= '$(\'.ban_bottom\').htm

  • Why does this JSON.parse return error: "unexpected token illegal"? 2011-09-04

    I'm using an AJAX request. This is the first time I'm using JSON or any of it's methods. The ajax utility returns an argument to the onreadystatechange callback as the responseText or responseXML of the file I'm requesting. Using a simple info.txt an

  • JQuery: Uncaught SyntaxError: Unexpected token ILLEGAL 2011-12-29

    I have this code and works well; $(".campodigitavel").change(function(){ $(".campocalculado").each(function(){ if ($(this).attr("ordem") == 1){ // O valor do primeiro item do grupo será o campo base para o cálculo. lnTotal = $(this).val(); } // Perco

  • Chrome: Uncaught Syntax Error : Unexpected token 2011-09-02

    Page here Seems like chrome is the only browser having problems with this bit of javascript. I have found that if I remove the '//' from the CDATA tags chrome will give me a line number for the error - line 48. I dont even know where start with this

  • error: Unexpected token ILLEGAL at Function () at assertExpression 2014-07-06

    I'm trying to use jade on building my views when I try to make a link on an image I get . How do I to fix this, please? Thanks in advance! --------------Solutions------------- Either the width and height attribute values need be quoted or you need to

  • Uncaught SyntaxError Unexpected Token illegal javascript with txt file 2012-11-22

    I'm testing a script to automate advertisement read from a txt file) i want to use this because it was the one i already had and was working and only needed a few changes, however, something stopped working and i dont know what's wrong, i'm checking

  • Uncaught syntax error : error unexpected token : while trying to consume Rails webservices 2012-05-02

    I am trying to use Ruby on Rails RESTful Webservices in my html page .. I got the json response but with an Uncaught syntax error : error unexpected token : .. I am trying to use that json data in an flexigrid .. This is my code ... <!-- Copyright

  • Syntax error, unexpected T_LNUMBER, expecting T_VARIABLE or '$' 2012-03-05

    I'm getting Syntax error, unexpected T_LNUMBER, expecting T_VARIABLE or '$' This is the code i'm using function wpse44503_filter_content( $content ) { $regex = '#src=("|\')'. '(/images/(19|20)(0-9){2}/(0|1)(0-9)/[^.]+\.(jpg|png|gif|bmp|jpeg))'. '("|\

  • Parse error: syntax error, unexpected end of file (Registration script) 2012-12-20

    I have a problem with my script :S This is the error:Parse error: syntax error, unexpected end of file Here is the full code.I searched for not closed bracklets or something but didn't found any :S I hope some of you guys can find the problem. <?p

  • JQuery/AJAX/PHP Error in Chrome Only: Unexpected token ILLEGAL 2011-08-06

    Using jQuery to make an AJAX call to a PHP file results in the following error in Chrome only: SyntaxError: Unexpected token ILLEGAL jQuery Snippet: $.ajax({ type: 'POST', url: 'ajax/Test_Get.php', dataType: 'json', data: { ID: settings.ID }, success

  • Javascript: Unexpected Token ILLEGAL Error with appendChild() 2011-09-17

    I'm new to javascript, but I'm getting an "Unexpected Token ILLEGAL" error with this line of code: switch (city) { case "london": var newdiv = document.createElement('<div id="london" class="option-area"><label class="city">From London to

  • jQuery: unexpected token ILLEGAL 2013-05-05

    This question already has an answer here: How do I break a string across more than one line of code in JavaScript? 8 answers Multi-line string insert using jQuery 2 answers could not find a solution to my problem so i'll ask here. When i insert jQuer

  • jquery AJAX Unexpected token illegal 2011-08-10

    I have this code to fetch profile pictures and messages: $(document).ready(function() { var url = "https://graph.facebook.com/search?q=cinema&type=post"; $.ajax({ type: "POST", url: url, dataType: "jsonp", success: function(msg){ console.log( msg

  • I have an error Uncaught SyntaxError: Unexpected token ILLEGAL 2012-02-01

    I parse JSON with eval() function ` and I have an error Uncaught SyntaxError: Unexpected token ILLEGAL this is my javascript code : var commentPerpost = document.getElementById('commentPerpost'); var response = eval('('+receiveReq.responseText+')');

  • Django forms + errors in JSON + jquery syntax error 2011-04-15

    I'm using a simple Django form with JSON validation. Following Jacobian method on how to expose form errors into a JSON object, I used this function: def errors_to_json(errors): # Force error strings to be un-lazied. return simplejson.dumps(dict((k,

Copyright (C) dskims.com, All Rights Reserved.

processed in 0.255 (s). 11 q(s)