JavaScript - Unterminated String Literal
I keep getting this error and I'm not sure why
var flashvars = {'regkey':"<?php $_GET[regkey]?>",'pkey':"<?php $_GET[pkey]?>"}; unterminated string literal [IMG]chrome://firebug/content/blank.gif[/IMG]var flashvars = {'regkey':"<br />\n Similar TutorialsHello, I created a simple WYSIWYG for creating CSS based webpages. It works exactly as assumed in Safari and Chrome. However, in firefox, when you copy/paste more than one line of text, instead of formatting it as html, in puts in line breaks causing the array storing all of the data to break into multiple lines and causing an unterminated string literal. Can anyone, 1. suggest why it is behaving this way? 2. suggest a work around to allow it to work on FF? So I can't figure out why I keep getting the error.... Code: unterminated string literal document.write("<input type=\"button\ value=\"" + phrases [i][j] + "\" Code: <form name="pirateForm"> <div align="center"> <script type="text/javascript"> phrases = [["Greetings","hello","pardon me","excuse me","hows it going"], ["People","sir","madam","woman","children"], ["Questions","where is","can you help me find","is that","how far is it to?"], ["Ariticles","the","my","your","there"], ["Adjectives","outstanding","attractive","happy","dead"], ["places","restroom","restaurant","hotel","pub"], ["Desires","I would like to","I desire","I wish I knew how to","my mother told me to"], ["Actions","have a great dinner","have a cocktail","fall on the ground","get drunk"]]; for(var i = 0; i < phrases.length; i++) { var category = phrases[i][0]; document.write("<tr valign='top'><td>" + category + ": <td>"); for(var j = 1; j < phrases [i].length; j+=2) { document.write("<input type=\"button\ value=\"" + phrases [i][j] + "\" onClick='document.pirateForm.Output.value += \"" + phrases [i][j+1] + "\";'>\n"); } } </script> </div> <div align="center"> <textarea id="task_list" rows="5" cols="130"></textarea> <input type="button" value="Clear" onClick="this.form.reset()" /> </div> </div> </form> Hi guys , i am getting this error " unterminated string literal" but iam unable to locate the problem..iam using fire bug for firefox.. any idea from where this error comes ? thanks im sure its the scripting, im new to js, can anyone Tell me why im getting these 2 error messages? thank you!!!!!!! detailed error: unterminated string literal Error: onPageUnload is not defined function writeMovie1() {detectBrowser();if(windowsInternetExplorer) {document.write('<object id="id3" classid="clsid:02BF25D5-8C17-4B23-BC80-D3488ABDDC6B" codebase="http://www.apple.com/qtactivex/qtplugin.cab" width="150" height="16" style="height: 0px; left: 160px; position: absolute; top: 150px; width: 150px; z-index: 1; "><param name="src" value="musicfiles/VenusStereo.m4a" /><param name="controller" value="false" /><param name="autoplay" value="true" /><param name="scale" value="tofit" /><param name="volume" value="100" /><param name="loop" value="true" /></object>');} else if(isiPhone) {document.write('<object id="id3" type="video/quicktime" width="150" height="16" style="height: 0px; left: 160px; position: absolute; top: 150px; width: 150px; z-index: 1; "><param name="src" value="musicfiles/VenusStereo.m4a"/><param name="controller" value="false"/><param name="scale" value="tofit"/></object>');} else {document.write('<object id="id3" type="video/quicktime" width="150" height="16" data="musicfiles/VenusStereo.m4a" style="height: 0px; left: 160px; position: absolute; top: 150px; width: 150px; z-index: 1; "><param name="src" value="musicfiles/VenusStereo.m4a"/><param name="controller" value="false"/><param name="autoplay" value="true"/><param name="scale" value="tofit"/><param name="volume" value="100"/><param name="loop" value="true"/></object>');} setTransparentGifURL('Media/transparent.gif');function applyEffects() {var registry=IWCreateEffectRegistry();registry.registerEffects({stroke_0:new IWStrokeParts([{rect:new IWRect(-5,5,10,467),url:'Welcome_files/stroke.png'},{rect:new IWRect(-5,-5,10,10),url:'Welcome_files/stroke_1.png'},{rect:new IWRect(5,-5,705,10),url:'Welcome_files/stroke_2.png'},{rect:new IWRect(710,-5,11,10),url:'Welcome_files/stroke_3.png'},{rect:new IWRect(710,5,11,467),url:'Welcome_files/stroke_4.png'},{rect:new IWRect(710,472,11,10),url:'Welcome_files/stroke_5.png'},{rect:new IWRect(5,472,705,10),url:'Welcome_files/stroke_6.png'},{rect:new IWRect(-5,472,10,10),url:'Welcome_files/stroke_7.png'}],new IWSize(716,477))});registry.applyEffects();} function hostedOnDM() {return true;} function onPageLoad() {loadMozillaCSS('Welcome_files/WelcomeMoz.css') adjustLineHeightIfTooBig('id1');adjustFontSizeIfTooBig('id1');adjustLineHeightIfTooBig('id2');adjust FontSizeIfTooBig('id2');Widget.onload();fixupAllIEPNGBGs();fixAllIEPNGs('Media/transparent.gif');applyEffects()} function onPageUnload() {Widget.onunload();} I get an error with the below statement. I'm sure it's the "+document.getElementById("sid").value++. How do I place that within my onclick event? Code: onClick="showHistory('Invoice_History.php?i=+document.getElementById("sid").value+&f=PICKUP_FROM','Invoice History')"; In JavaScript, I am printing the values as <script>alert('<%=status%>')</script> Javascript error - Unterminated string constant. In JSP I am getting status variable as <% status = instanceObj.get("status");%> status value - ({ selected:null, field:"[\r {\r name:\"shipmentno\", \r width:null\r }, \r {\r name:\"selection\", \r width:50\r }, \r {\r name:\"invoicenumber\", \r width:null\r }, \r {\r name:\"issuedate\", \r width:122\r }, \r {\r name:\"buyername\", \r width:null\r }, \r {\r name:\"buyercountry\", \r width:null\r }, \r {\r name:\"sellername\", \r width:null\r }, \r {\r name:\"sellercountry\", \r width:null\r }, \r {\r name:\"currency\", \r width:null\r }, \r {\r name:\"amount\", \r width:null\r }, \r {\r name:\"status\", \r width:null\r }, \r {\r name:\"substatus\", \r width:null\r }, \r {\r name:\"lastAction\", \r width:null\r }\r]", sort:"({\r fieldName:null, \r sortDir:true\r})" }) This is happening since, selected: , field: and sort: are coming on next line.. Please suggest some solution. I am trying to open a link in a new window and get this error. What am i doing wrong on the code below: Code: <a onclick="window.open('http://c1739202.cdn.cloudfiles.rackspacecloud.com/Assignments_final_demo.htm' width=" height='860,menubar=no,status=no,"' location="no,toolbar=no,scrollbars=no')"" c1739202.cdn.cloudfiles.rackspacecloud.com window.open(?http: 1155, Assignments_final_demo.htm?,?> <img alt="" hspace="0" src="/files/images/PUdropBoxDemoButton.jpg" align="default" border="0" /></a></div> ok so Code: <p> Howdy <p> expressed as a literal string that is passed to the setTimeout() function might look like this: Code: setTimeout("document.getElementById('first').innerHTML = '<p>' + 'HOWDY' + '<\/p>';", 2000); ..so I guess you can't just put quotes around an expression like this: "'<p> HOWDY <\/p>;" So tags have to be isolated, but it get confusing with expressions like this, which I am not sure how to express as a string: Code: <p><h2 class="pos_left"> <img src="car1.jpg" name="slide" width="400" height="250" /> </h2> </p> ^ I wish I could change the " in there to ' and then just wrap the whole thing in double " This is what I came up with but it did not work: Code: setTimeout("document.getElementById('first').innerHTML = '<p>' + '<h2' + 'class='pos_left'' + '>' + '<img' + 'src='car1.jpg'' + 'name='slide'' + 'width='400'' + 'height='250'' + '/>' + '</h2>' + '<\/p>';", 4000); I have the following code which attaches a function to events in x number of comboboxes (x will probably always = 4, but I do not want to hard-code this). I wish to pass the value of i to the function being attached as well as the value of tempData. In other words, I want the parameters in function to be the value, not a reference variable. In the current example, I am using the hard-coded variable ci. This I want to be replaced by a literal created when the event handler is attached (the value of the loop variable i). Also, notice that I get the filter value in the event handler (assigned to the variable ct). I would like to replace this code with the value of tempData which would also be determined when the evenet is attached (it is the same value in this case, but it keeps the onChange event from having to do this each time it runs). Code: var props = { col_0: "select", col_1: "select", col_2: "select", col_3: "select", btn_reset:true, display_all_text: "-Show All-", on_filters_loaded: function(o){ //reset all filters var slcIndexes = o.GetFiltersByType(o.fltTypeSlc, true); //o.fltTypeSlc = 'select' for(var i=0; i<slcIndexes.length; i++){ //this public method returns a filter DOM element by column index var slcElm = o.GetFilterElement(slcIndexes[i]); //tempData = slcElm.options[slcElm.selectedIndex].text; //window.alert(tempData + " " + slcElm); tf_AddEvent(slcElm, 'change', onchangeFn=function(){ //ci is the column index for the column to filter on. ct is the new text from the combobox to filter on var ci; ci = 2; var ct = tf_outputTable.GetFilterValue(ci); tf_outputTable.ClearFilters(); //window.alert("ci= " + ci + " ct= " + ct); tf_outputTable.SetFilterValue(ci, ct); tf_outputTable.Filter(); }); //end tf_AddEvent } } } setFilterGrid("outputTable",props); I need to find a way to check if a field contains sql commands. To begin with, lets just say as an example:select, delete, drop, truncate <script type="text/javascript"> function validate () { var literals= /select/; user_input = document.forms[0].input1.value.search(literals); if (user_input == -1) { alert("test123"); } } </script> <body> <form > <input type="text" size="25" name="input1" value=" "> <input type="button" onClick="validate()" value="check" /> </form> I am new to JS and regular experssions. How do I make it in my regular expression so not only am I searching for /select/ but also for the other sql commands (or anythign for that matter)... essentially multiple literals... eg if it contains /select OR delete OR truncate/ etc. sorry if this is confusing. let me know if i can help in any other way. thanks guys! Hello, I have the following code: A = { "value" : "a", }; B = A ; B.value = "b"; alert (A.value); // => b I expected A.value to be "a". Can someone explain what I'm thinking wrong? And: how can I change values of a new object, without changing the parent-object ? tnx Hi.. I am facing identifier starts immediately after numeric literal error in firefox onclick="document.location.href='<%= themeDisplay.getPathMain() %>/portal/ext/asite/assignOrg'"/> can any 1 solve this?? Hey all, I have a simple example below showing how when I pass in the value of the value attribute of option node, and then use if operator to check whether parameter is a string or not, even though it's a string, it converts it to false boolean and triggers the else statement rather than calling a function: Code: <body> <select> <option value="createMsg">Add Message</option> <option value="removeMsg">Remove Message</option> </select> </body> Code: var menu = { handleMenu : function(callback){ if(callback === "string"){ menu[callback](); } else { console.log("Issue occurred") } }, createMsg : function(){ var content = document.createTextNode("Please give additional information."), heading = document.createElement("h1"); heading.appendChild(content); document.body.appendChild(heading); }, removeMsg : function(){ } } document.getElementsByTagName('select')[0].onchange = function(){ menu.handleMenu(this.value)}; callback should be a string so why is it saying otherwise? Thanks for response I am trying to use some string functions with no results. It appear what I'm using them on are not strings. my_string = document.getElementById("link5").onclick; document.write(my_string.lastIndexOf("5")); This gets nothing! And document.write(document.getElementById("link5").onclick.lastIndexOf("5")); gets nothing. BUT if I make a string and put what the onclick is set to with: my_string = "function onclick(event) { reveal(\"5\", \"2\", \"1864\")"; then my_string.lastIndexOf("5") will yield 34. So why is my original my_string = not working? And how can I get it to work? I was looking at this page, and came across "%" used in strange context. It appears that the mod operator can be used in Strings?? http://download.oracle.com/javase/tu...vaOO/enum.html What does this do/ mean? Thanks!!: System.out.printf("Your weight on %s is %f%n", p, p.surfaceWeight(mass)); This is probably easy if I knew Javascript. Can someone show me the code to get the number "800014352" part from the url???? http://testebiz/ebizbtest/ShoppingCa...2/Default.aspx I need help with the following code below. It just doesn't turn out okay. Any ideas? Code: function changing() { A = document.exempel.Amount.value B = ("<%#Container.DataItem("Price_2_qty")%>") C = ("<%#Container.DataItem("Price_3_qty")%>") D = ("<%#Container.DataItem("Price_4_qty")%>") E = ("<%#Container.DataItem("Price_5_qty")%>") if (A < B) {document.exempel.Price.value = "<%#Container.DataItem("Price_1")%>"} else if (A = B && (!(A >= C))) {document.exempel.Price.value = "<%#Container.DataItem("Price_2")%>"} else if (A = C && (!(A >= D))) {document.exempel.Price.value = "<%#Container.DataItem("Price_3")%>"} else if (A = D && (!(A >= E))) {document.exempel.Price.value = "<%#Container.DataItem("Price_4")%>"} else if (A >= E) {document.exempel.Price.value = "<%#Container.DataItem("Price_5")%>"} } Hello, I need your help. For one reason or another, I have a textarea with text in it, however, when I call it back and store it in var, it seems to strip all the spaces. [ID = "COMMENTS"] Ie. of what's in the textarea: ---------------------------------------------- Apples are red Oranges are orange Pears are green Bananas are yellow var comments = document.getElementById("comments").value returns: Apples are red Oranges are orange Pears are green Bananas are yellow How could this be re-written such that the spaces in between the text aren't ignored? Much thanks and appreciation for everyones help. Cheers J Hello, I need your help. Let's say for example if I have the following file number: 2011-1234567 and if the value of the variable is already the same (ie. var fileNo = 2011-1234567) how can I go about automatically adding a number at the end? ex.1.) var fileNo = "2011-1234567" if (fileNo already exists) { fileNo = 2011-1234567-2 } ex.2.) var fileNo = "2011-1234567-2" if (fileNo already exists) { fileNo = 2011-1234567-3 } ect. Much thanks and appreciation for all your help. Jay |