From lists at pruimphotography.com Fri Oct 1 20:47:25 2010 From: lists at pruimphotography.com (Jason Pruim) Date: Fri, 1 Oct 2010 21:47:25 -0400 Subject: [Javascript] Javascript include problem? Message-ID: Hey Everyone, I just signed up for the list and I can't wait to get really deep into javascript and be able to make amazing things happen. But right now I'm running into a small problem... I have a javascript page that I am including in a combination php/html page. (Yes I'm going for everything! :)) and the javascript works just fine if I load the page independently but when I try and view it via an include it won't display the map... Link for the stand alone page: HTTP://jason.pruimphotography.com/dev/cms2/includes/google/testmap.html Link for included page: HTTP://jason.pruimphotography.com/dev/cms2/events/display1.php?id=46 Any idea what the problem is? :) Thanks in advance for any help or pointers you can give! :) From johnlist at gulfbridge.net Fri Oct 1 21:14:26 2010 From: johnlist at gulfbridge.net (John List) Date: Fri, 01 Oct 2010 22:14:26 -0400 Subject: [Javascript] Javascript include problem? In-Reply-To: References: Message-ID: <4CA69582.1050405@gulfbridge.net> On 10/01/2010 09:47 PM, Jason Pruim wrote: > Hey Everyone, > > I just signed up for the list and I can't wait to get really deep into > javascript and be able to make amazing things happen. > > But right now I'm running into a small problem... > > I have a javascript page that I am including in a combination php/html > page. (Yes I'm going for everything! :)) and the javascript works just > fine if I load the page independently but when I try and view it via > an include it won't display the map... > > Link for the stand alone page: > HTTP://jason.pruimphotography.com/dev/cms2/includes/google/testmap.html > > Link for included page: > HTTP://jason.pruimphotography.com/dev/cms2/events/display1.php?id=46 > > Any idea what the problem is? :) > Thanks in advance for any help or pointers you can give! :) Jason, it looks like your "javascript page" is a complete html page, not just javascript. You are including that in another html page, so you wind up with multiple , , and tags. Put your javascript only (no html) in its own .js file, and reference that file in a tags in the head of the page.) Hope that helps, John From lists at pruimphotography.com Sat Oct 2 09:17:06 2010 From: lists at pruimphotography.com (Jason Pruim) Date: Sat, 2 Oct 2010 10:17:06 -0400 Subject: [Javascript] Javascript include problem? In-Reply-To: <4CA69582.1050405@gulfbridge.net> References: <4CA69582.1050405@gulfbridge.net> Message-ID: <14289148-D8AE-4D76-A714-2284A80B060D@pruimphotography.com> On Oct 1, 2010, at 10:14 PM, John List wrote: > On 10/01/2010 09:47 PM, Jason Pruim wrote: >> Hey Everyone, >> >> I just signed up for the list and I can't wait to get really deep >> into javascript and be able to make amazing things happen. >> >> But right now I'm running into a small problem... >> >> I have a javascript page that I am including in a combination php/ >> html page. (Yes I'm going for everything! :)) and the javascript >> works just fine if I load the page independently but when I try and >> view it via an include it won't display the map... >> >> Link for the stand alone page: HTTP://jason.pruimphotography.com/dev/cms2/includes/google/testmap.html >> >> Link for included page: HTTP://jason.pruimphotography.com/dev/cms2/events/display1.php?id=46 >> >> Any idea what the problem is? :) >> Thanks in advance for any help or pointers you can give! :) > > Jason, it looks like your "javascript page" is a complete html page, > not just javascript. You are including that in another html page, so > you wind up with multiple , , and tags. > > Put your javascript only (no html) in its own .js file, and > reference that file in a and a php include) Neither worked... had the same result... I'm wondering if something with the include is messing it up? Should I just try and put the whole thing in a in the head of the file? Not the most portable but if it would work... THanks again for your help John! > > > _______________________________________________ > Javascript mailing list > Javascript at lists.evolt.org > http://lists.evolt.org/mailman/listinfo/javascript From mdougherty at pbp.com Sat Oct 2 10:37:04 2010 From: mdougherty at pbp.com (Mike Dougherty) Date: Sat, 2 Oct 2010 11:37:04 -0400 Subject: [Javascript] Javascript include problem? In-Reply-To: <4CA69582.1050405@gulfbridge.net> References: <4CA69582.1050405@gulfbridge.net> Message-ID: On Fri, Oct 1, 2010 at 10:14 PM, John List wrote: > > Jason, it looks like your "javascript page" is a complete html page, not > just javascript. You are including that in another html page, so you wind up > with multiple , , and tags. > > Put your javascript only (no html) in its own .js file, and reference that > file in a tags in the head of > the page.) > > fwiw the external script ( ) guarantees that the extra X bytes will be downloaded with the markup on every page request. btw, by the time I was looking it appeared the problem was resolved. From john at jwarner.com Sat Oct 2 10:36:41 2010 From: john at jwarner.com (John Warner) Date: Sat, 2 Oct 2010 11:36:41 -0400 Subject: [Javascript] Javascript include problem? In-Reply-To: <14289148-D8AE-4D76-A714-2284A80B060D@pruimphotography.com> References: <4CA69582.1050405@gulfbridge.net> <14289148-D8AE-4D76-A714-2284A80B060D@pruimphotography.com> Message-ID: <1ce601cb6247$9c95bc90$d5c135b0$@com> Not sure on PHP (I'm a ASP.NET guy) but it sounds like you are still not understanding what John was suggesting (note I'm a different John) Your JavaScript file (.js) will contain only JavaScript, absolutely no html markup nor should any PHP be present. Of course you can bury anything in comments. Inside the js file there are no Clear as mud right :-) John Warner > -----Original Message----- > From: javascript-bounces at lists.evolt.org [mailto:javascript- > bounces at lists.evolt.org] On Behalf Of Jason Pruim > Sent: Saturday, October 02, 2010 10:17 AM > To: JavaScript List > Subject: Re: [Javascript] Javascript include problem? > > > On Oct 1, 2010, at 10:14 PM, John List wrote: > > > On 10/01/2010 09:47 PM, Jason Pruim wrote: > >> Hey Everyone, > >> > >> I just signed up for the list and I can't wait to get really deep > >> into javascript and be able to make amazing things happen. > >> > >> But right now I'm running into a small problem... > >> > >> I have a javascript page that I am including in a combination php/ > >> html page. (Yes I'm going for everything! :)) and the javascript > >> works just fine if I load the page independently but when I try and > >> view it via an include it won't display the map... > >> > >> Link for the stand alone page: > HTTP://jason.pruimphotography.com/dev/cms2/includes/google/testmap.html > >> > >> Link for included page: > HTTP://jason.pruimphotography.com/dev/cms2/events/display1.php?id=46 > >> > >> Any idea what the problem is? :) > >> Thanks in advance for any help or pointers you can give! :) > > > > Jason, it looks like your "javascript page" is a complete html page, > > not just javascript. You are including that in another html page, so > > you wind up with multiple , , and tags. > > > > Put your javascript only (no html) in its own .js file, and > > reference that file in a and a php include) > > Neither worked... had the same result... I'm wondering if something > with the include is messing it up? Should I just try and put the whole > thing in a in the head of the file? Not the most > portable but if it would work... > > THanks again for your help John! > > > > > > > > _______________________________________________ > > Javascript mailing list > > Javascript at lists.evolt.org > > http://lists.evolt.org/mailman/listinfo/javascript > > _______________________________________________ > Javascript mailing list > Javascript at lists.evolt.org > http://lists.evolt.org/mailman/listinfo/javascript From lists at pruimphotography.com Sat Oct 2 10:45:13 2010 From: lists at pruimphotography.com (Jason Pruim) Date: Sat, 2 Oct 2010 11:45:13 -0400 Subject: [Javascript] Javascript include problem? In-Reply-To: References: <4CA69582.1050405@gulfbridge.net> Message-ID: <8FAAAA2D-123C-4CB8-9CE2-9A707E55176C@pruimphotography.com> On Oct 2, 2010, at 11:37 AM, Mike Dougherty wrote: > On Fri, Oct 1, 2010 at 10:14 PM, John List > wrote: > >> >> Jason, it looks like your "javascript page" is a complete html >> page, not >> just javascript. You are including that in another html page, so >> you wind up >> with multiple , , and tags. >> >> Put your javascript only (no html) in its own .js file, and >> reference that >> file in a tags in >> the head of >> the page.) >> >> > fwiw the external script ( ) > guarantees > that the extra X bytes will be downloaded with the markup on every > page > request. > > btw, by the time I was looking it appeared the problem was resolved. > _______________________________________________ > Javascript mailing list > Javascript at lists.evolt.org > http://lists.evolt.org/mailman/listinfo/javascript Hi Mike, I'll start changing all my stuff to use the external script commands then :) But with the caching... Would it store all the variables as well? What the whole page is doing is simply displaying a google map of a point that is retrieved from my database... So caching isn't necessarily what I'm looking for... Unless it would refresh the variable with the ID number but store the rest of the script... You also said it worked? What browser are you using and what page are you visiting? :) I'm still fighting with it hehehe :) From lists at pruimphotography.com Sat Oct 2 10:49:16 2010 From: lists at pruimphotography.com (Jason Pruim) Date: Sat, 2 Oct 2010 11:49:16 -0400 Subject: [Javascript] Javascript include problem? In-Reply-To: <1ce601cb6247$9c95bc90$d5c135b0$@com> References: <4CA69582.1050405@gulfbridge.net> <14289148-D8AE-4D76-A714-2284A80B060D@pruimphotography.com> <1ce601cb6247$9c95bc90$d5c135b0$@com> Message-ID: <709BB428-95F1-4998-A48C-FDD3237EF45B@pruimphotography.com> On Oct 2, 2010, at 11:36 AM, John Warner wrote: > Not sure on PHP (I'm a ASP.NET guy) but it sounds like you are still > not > understanding what John was suggesting (note I'm a different John) > > Your JavaScript file (.js) will contain only JavaScript, absolutely no > html markup nor should any PHP be present. Of course you can bury > anything > in comments. Inside the js file there are no > > > onClick="helloJason();" /> > > > > Clear as mud right :-) > > John Warner Hi Other John! :) I think I have the concept down... I was just throwing out ideas for including the page wether it was just javascript, or a complete page into my other page (The one I actually want it to display on) This is all that is in my javascript file right now: var gmarkers = []; var htmls = []; var to_htmls = []; var from_htmls = []; var i=0; // functions that open the directions forms function tohere(i) { gmarkers[i].openInfoWindowHtml(to_htmls[i]); } function fromhere(i) { gmarkers[i].openInfoWindowHtml(from_htmls[i]); } // Check to see if this browser can run the Google API // Display the map, with some controls and set the initial location function load() { if (GBrowserIsCompatible()) { var map = new GMap2(document.getElementById("map")); map.addControl(new GLargeMapControl()); map.addControl(new GMapTypeControl()); // Set up markers with info windows GDownloadUrl("phpsqlajax_genxml3.php", function(data) { var xml = GXml.parse(data); var markers = xml.documentElement.getElementsByTagName("marker"); for (var i = 0; i < markers.length; i++) { var name = markers[i].getAttribute("name"); var address = markers[i].getAttribute("address"); var type = markers[i].getAttribute("type"); var summary = markers[i].getAttribute("summary"); var description = markers[i].getAttribute("description"); var point = new GLatLng(parseFloat(markers[i].getAttribute("lat")), parseFloat(markers[i].getAttribute("lng"))); var marker = createMarker(point, name, address, type, summary); map.addOverlay(marker); map.setCenter(new GLatLng(parseFloat(markers[i].getAttribute("lat")), parseFloat(markers[i].getAttribute("lng"))), 11); } }); // A function to create the marker and set up the event window function createMarker(point, name, html, address, summary) { var marker = new GMarker(point); html = 'Name: ' + name + '
Address: ' + address + '
Summary: ' +summary; // The info window version with the "to here" form open to_htmls[i] = html + '
Directions: To here - From here' + '
Start address:
' + '
' + '' + ''; // The info window version with the "to here" form open from_htmls[i] = html + '
Directions: From here - To here' + '
End address:' + '
' + '' + ''; // The inactive version of the direction info html = html + '
Directions: To here - From here'; GEvent.addListener(marker, "click", function() { marker.openInfoWindowHtml(html); }); gmarkers[i] = marker; htmls[i] = html; i++; return marker; } } } Thanks for looking! :) From mdougherty at pbp.com Sat Oct 2 14:55:35 2010 From: mdougherty at pbp.com (Mike Dougherty) Date: Sat, 2 Oct 2010 15:55:35 -0400 Subject: [Javascript] Javascript include problem? In-Reply-To: <8FAAAA2D-123C-4CB8-9CE2-9A707E55176C@pruimphotography.com> References: <4CA69582.1050405@gulfbridge.net> <8FAAAA2D-123C-4CB8-9CE2-9A707E55176C@pruimphotography.com> Message-ID: On Sat, Oct 2, 2010 at 11:45 AM, Jason Pruim wrote: > I'll start changing all my stuff to use the external script commands then > :) But with the caching... Would it store all the variables as well? What > the whole page is doing is simply displaying a google map of a point that is > retrieved from my database... So caching isn't necessarily what I'm looking > for... Unless it would refresh the variable with the ID number but store the > rest of the script... > > You also said it worked? What browser are you using and what page are you > visiting? :) I'm still fighting with it hehehe :) > > "worked" is open to interpretation I guess - I didn't see any errors or particular ugliness. I have no idea how much of what I'm not seeing is broken vs. not-yet-implemented. I guess I gave large benefit of the doubt :) when you ask "would it store my variables" - are you sure your declarations are 'variable' if they're hardcoded in a file now? Typically you would have let's call it 8-10k worth of function definitions and other program code to make your page work. If you have less than 1k worth of data that changes frequently compared to the program code, for example: weather details, then consider: Put the program code in one script file and the data in another file. Reference both in your markup. The browser will request the program code effectively, "Hey, has the file I downloaded last week with X timestamp+bytecount still fresh?" If the server says, "Yup, that's what I'd serve up: use it" then you save the time it takes to download 8-10k worth of code the browser already has. Then the browser says, "What about this data file I have from 5 days ago?" and the server responds, "No I update this file hourly, here's the 1k of new data" Instead of downloading markup(4k)+program(10k)+data(1k)=15k, you download markup(4k)+program(cached)+data(1k)=5k and your page is ready 66% quicker. If it sounds like I'm just being a kook about a few bytes, download the YSlow extension to Firebug (in Firefox) and examine the page weights of "unprimed cache" vs "primed cache" and qualitatively feel the difference between a content-rich page like cnn.com on first-download and subsequent requests. (1141.4K vs 109.4K) The takeaway (if there is one) is that you build for performance from day 1 - high performance is not something you can add-on at the end of a project when you find that it's too slow/clunky for anyone to tolerate. I would also preemptively counter the "Oh this is just a small project I'm doing for fun, so it doesn't really matter" with the suggestion that small/fun projects are how you learn to do things the proper way - so when you get the large project you already have good habits/skills. Then of course the project manager/boss will push you to cut corners for the sake of time/money budgets :) From lists at pruimphotography.com Sat Oct 2 15:20:59 2010 From: lists at pruimphotography.com (Jason Pruim) Date: Sat, 2 Oct 2010 16:20:59 -0400 Subject: [Javascript] Javascript include problem? In-Reply-To: References: <4CA69582.1050405@gulfbridge.net> <8FAAAA2D-123C-4CB8-9CE2-9A707E55176C@pruimphotography.com> Message-ID: <6812D8A2-9E43-4C8D-BBD2-0B2DD471CAE5@pruimphotography.com> On Oct 2, 2010, at 3:55 PM, Mike Dougherty wrote: > On Sat, Oct 2, 2010 at 11:45 AM, Jason Pruim >wrote: > >> I'll start changing all my stuff to use the external script >> commands then >> :) But with the caching... Would it store all the variables as >> well? What >> the whole page is doing is simply displaying a google map of a >> point that is >> retrieved from my database... So caching isn't necessarily what I'm >> looking >> for... Unless it would refresh the variable with the ID number but >> store the >> rest of the script... >> >> You also said it worked? What browser are you using and what page >> are you >> visiting? :) I'm still fighting with it hehehe :) >> >> > "worked" is open to interpretation I guess - I didn't see any errors > or > particular ugliness. I have no idea how much of what I'm not seeing > is > broken vs. not-yet-implemented. I guess I gave large benefit of the > doubt > :) The site is nearly done... Just need to polish it a little bit and get the map working! :) > > when you ask "would it store my variables" - are you sure your > declarations > are 'variable' if they're hardcoded in a file now? The way the site is working right now (All done from examples I've found on the net so it may not be the best way...) The file that is referenced in the GDownloadURL grabs the info from the database and puts it into an XML format which is then passed into the javascript to process the XML and plot it out on the map. The map should be displaying a single point on the map centered over that point along with the address below it and brief info about the event. All of that is working perfectly fine as long as the html/javascript is in the same page AND not included in my final display page... Once I try and include it all I get is a grey box along with the google buttons... > > Typically you would have let's call it 8-10k worth of function > definitions > and other program code to make your page work. If you have less > than 1k > worth of data that changes frequently compared to the program code, > for > example: weather details, then consider: Put the program code in > one script > file and the data in another file. Reference both in your markup. > The > browser will request the program code effectively, "Hey, has the > file I > downloaded last week with X timestamp+bytecount still fresh?" If > the server > says, "Yup, that's what I'd serve up: use it" then you save the time > it > takes to download 8-10k worth of code the browser already has. Then > the > browser says, "What about this data file I have from 5 days ago?" > and the > server responds, "No I update this file hourly, here's the 1k of new > data" > Instead of downloading markup(4k)+program(10k)+data(1k)=15k, you > download > markup(4k)+program(cached)+data(1k)=5k and your page is ready 66% > quicker. really? That much extra? Wow... Javascript will take some getting used to :) > > If it sounds like I'm just being a kook about a few bytes, download > the > YSlow extension to Firebug (in Firefox) and examine the page weights > of > "unprimed cache" vs "primed cache" and qualitatively feel the > difference > between a content-rich page like cnn.com on first-download and > subsequent > requests. (1141.4K vs 109.4K) > > The takeaway (if there is one) is that you build for performance > from day 1 > - high performance is not something you can add-on at the end of a > project > when you find that it's too slow/clunky for anyone to tolerate. I > would > also preemptively counter the "Oh this is just a small project I'm > doing for > fun, so it doesn't really matter" with the suggestion that small/fun > projects are how you learn to do things the proper way - so when you > get the > large project you already have good habits/skills. Then of course the > project manager/boss will push you to cut corners for the sake of > time/money > budgets :) The nice thing about being a freelancer is I'm the boss :) So I'll just build extra time into the quotes if I decide to keep pursuing my venture into Javascript... Which I most likely will... I'm very intrigued by it, but it's a BIG jump from PHP which is where most of my knowledge comes from. Thanks again! :) From mdougherty at pbp.com Sat Oct 2 20:05:30 2010 From: mdougherty at pbp.com (Mike Dougherty) Date: Sat, 2 Oct 2010 21:05:30 -0400 Subject: [Javascript] Javascript include problem? In-Reply-To: <6812D8A2-9E43-4C8D-BBD2-0B2DD471CAE5@pruimphotography.com> References: <4CA69582.1050405@gulfbridge.net> <8FAAAA2D-123C-4CB8-9CE2-9A707E55176C@pruimphotography.com> <6812D8A2-9E43-4C8D-BBD2-0B2DD471CAE5@pruimphotography.com> Message-ID: On Sat, Oct 2, 2010 at 4:20 PM, Jason Pruim wrote: > The nice thing about being a freelancer is I'm the boss :) So I'll just > build extra time into the quotes if I decide to keep pursuing my venture > into Javascript... Which I most likely will... I'm very intrigued by it, but > it's a BIG jump from PHP which is where most of my knowledge comes from. > The more you use it, the quicker you will become. Either you will adopt a framework like jQuery or you'll end up with a standard set of tricks you figured out on your own (which becomes your custom framework) Something about how you described the problem in your most recent email makes me wonder if you would benefit from labjs.com. It's a convenient library to manage dynamically adding script to your page. There are others with allegedly easier to understand usage but I found labjs to be very straightforward. Also, If you haven't already seen json.org I suggest you check it out. XML is likely to be the most-cited format for exchanging data (ex: SOAP) - but especially for javascript and especially for applications where you control both the server and the client, the json format for data is very convenient. Do continue to share here with the rest of us. :) From riegel at clearimageonline.com Sat Oct 2 20:43:24 2010 From: riegel at clearimageonline.com (Terry Riegel) Date: Sat, 2 Oct 2010 21:43:24 -0400 Subject: [Javascript] RFC clearjs.org In-Reply-To: References: <4CA69582.1050405@gulfbridge.net> <8FAAAA2D-123C-4CB8-9CE2-9A707E55176C@pruimphotography.com> <6812D8A2-9E43-4C8D-BBD2-0B2DD471CAE5@pruimphotography.com> Message-ID: <04A92FAC-2956-40F6-91FB-0837B27E9790@clearimageonline.com> Hello All, I wrote my first AJAX library and wonder if any on this list would be willing to look at it and offer a critique. I am also interested in building the examples with PHP also. I have never used PHP and am looking for some help with that. Thanks for any input. Terry Riegel From andre at oire.org Wed Oct 20 11:49:09 2010 From: andre at oire.org (Andre Polykanine) Date: Wed, 20 Oct 2010 19:49:09 +0300 Subject: [Javascript] onChange event not firing at all Message-ID: <1774672474.20101020194909@oire.org> Hi everyone, Here's a simple form. For unknown reason the onChange event does fire only when the Tab key is pressed (as if it was an onBlur handler). More than that, the remaining chars number is increasing only by one. Any ideas, please? Here's the code. I'm using jQuery 1.4.3.
Leave me a note: Chars remaining:

If you're seeing this message, then you have disabled JavaScrip? support. In order to have all functionality on our website, you must enable JavaScript support.

-- With best regards from Ukraine, Andre Skype: Francophile Twitter: http://twitter.com/m_elensule Facebook: http://facebook.com/menelion From mdougherty at pbp.com Wed Oct 20 11:52:28 2010 From: mdougherty at pbp.com (Mike Dougherty) Date: Wed, 20 Oct 2010 12:52:28 -0400 Subject: [Javascript] onChange event not firing at all In-Reply-To: <1774672474.20101020194909@oire.org> References: <1774672474.20101020194909@oire.org> Message-ID: On Wed, Oct 20, 2010 at 12:49 PM, Andre Polykanine wrote: > Hi everyone, > Here's a simple form. For unknown reason the onChange event does fire > only when the Tab key is pressed (as if it was an onBlur handler). > More than that, the remaining chars number is increasing only by one. > Any ideas, please? > If you want to trap key events, use the appropriate onKey* method. I am not sure the onChange event is fired consistently on every browser - it sounds like it's only checked upon the control losing focus. It makes sense even if it's annoying in this case. :) From david at dorward.me.uk Wed Oct 20 11:53:45 2010 From: david at dorward.me.uk (David Dorward) Date: Wed, 20 Oct 2010 17:53:45 +0100 Subject: [Javascript] onChange event not firing at all In-Reply-To: <1774672474.20101020194909@oire.org> References: <1774672474.20101020194909@oire.org> Message-ID: On 20 Oct 2010, at 17:49, Andre Polykanine wrote: > Here's a simple form. For unknown reason the onChange event does fire > only when the Tab key is pressed (as if it was an onBlur handler). Because that is what is supposed to happen: "the event is deferred until the element loses focus." ? http://api.jquery.com/change/ Use a keypress event if you want it to happen on a keypress. > More than that, the remaining chars number is increasing only by one. $(this).length is the number of elements in the jQuery selector - which is always going to be 1. You want something more along the lines of: remaining = max_length = $(this).val().length; -- David Dorward http://dorward.me.uk From alberto.domingo at uah.es Tue Oct 12 09:00:19 2010 From: alberto.domingo at uah.es (Alberto Domingo) Date: Tue, 12 Oct 2010 16:00:19 +0200 Subject: [Javascript] Firefox: Script removed by snapshot save (when saving generated html page) Message-ID: Hello everybody, Do you know the origin of this behavior? I use a lot javascript and html to create other pages. I do it for my personal use, so there is nothing obscure behind. I use firefox because the generated code can be saved and creates a working page. I use to create not only the html code but also javascript scripts, I have been doing this for years, and everything was perfect, but for some reason (update? Plugins? Complements?) now the contents of the script tag is replaced by this thext: /* Script removed by snapshot save */ Not only in the html document, but also if this document calls an external .js file, the file contents is replaced by the same text when saved. Any idea about the origin? Is it possible to disable this feature? (In my firefox, of course!!) Thanks in advace. Alberto. Here is a test code (also included in the attached zip file) From mdougherty at pbp.com Sat Oct 23 11:55:33 2010 From: mdougherty at pbp.com (Mike Dougherty) Date: Sat, 23 Oct 2010 16:55:33 -0000 Subject: [Javascript] Firefox: Script removed by snapshot save (when saving generated html page) In-Reply-To: References: Message-ID: On Tue, Oct 12, 2010 at 10:00 AM, Alberto Domingo wrote: > var t = ""; > t += "\r"; > t += "\r"; > t += ""; > t += "GENERATED PAGE"; > t += "\r"; > t += "\r"; > t += "\r"; > t += "\r"; > t += "var a = 1;"; > t += "\r"; > t += "\r"; > t += "\r"; > t += "Save this page and look at the saved code. Also in the associated > folder, look at the scripts." > t += "\r"; > t += "\r"; > t += "\r"; > t += "\r"; > I don't understand why people use this pattern. Why not reduce all those += to a single assignment: var t = "" + "" + " + .... etc. Or if you really need granular/line-by-line string building (loop iteration, complex flow) var a = []; a.push( "<html>" ); a.push( etc ); var t = a.join(""); /* or a.join("\r") if you really want the line breaks in source */