<?xml version='1.0' encoding='utf-8' ?>

<rss version='2.0' xmlns:lj='http://www.livejournal.org/rss/lj/1.0/' xmlns:atom10='http://www.w3.org/2005/Atom'>
<channel>
  <title>Javascript</title>
  <link>https://javascript.dreamwidth.org/</link>
  <description>Javascript - Dreamwidth Studios</description>
  <lastBuildDate>Sun, 09 Jun 2019 11:00:15 GMT</lastBuildDate>
  <generator>LiveJournal / Dreamwidth Studios</generator>
  <lj:journal>javascript</lj:journal>
  <lj:journaltype>community</lj:journaltype>
  <image>
    <url>https://v2.dreamwidth.org/474369/505336</url>
    <title>Javascript</title>
    <link>https://javascript.dreamwidth.org/</link>
    <width>100</width>
    <height>100</height>
  </image>

<item>
  <guid isPermaLink='true'>https://javascript.dreamwidth.org/1162.html</guid>
  <pubDate>Sun, 09 Jun 2019 11:00:15 GMT</pubDate>
  <title>Inconsistent Javascript</title>
  <link>https://javascript.dreamwidth.org/1162.html</link>
  <description>Posted by: &lt;span lj:user=&apos;tornir&apos; style=&apos;white-space: nowrap;&apos; class=&apos;ljuser&apos;&gt;&lt;a href=&apos;https://tornir.dreamwidth.org/profile&apos;&gt;&lt;img src=&apos;https://www.dreamwidth.org/img/silk/identity/user.png&apos; alt=&apos;[personal profile] &apos; width=&apos;17&apos; height=&apos;17&apos; style=&apos;vertical-align: text-bottom; border: 0; padding-right: 1px;&apos; /&gt;&lt;/a&gt;&lt;a href=&apos;https://tornir.dreamwidth.org/&apos;&gt;&lt;b&gt;tornir&lt;/b&gt;&lt;/a&gt;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;Code below updated 10 Jun 12:50.&lt;br /&gt;&lt;s&gt;I&apos;m trying to get the (x,y) sizes of two images for use in later calculations.&lt;br /&gt;In FF67, the test page loads, as do the images, but the reported sizes are all zero, however, if I press F5 and reload, the page works perfectly.&lt;br /&gt;In Chrome75, despite loading, the image sizes are consistently zero, and the code crashes after test 3.&lt;br /&gt;Can anyone see what I&apos;m doing wrong?&lt;/s&gt;&lt;br /&gt;&lt;br /&gt;The initial problem&apos;s been sorted by using onload to call routines to get the image sizes after they&apos;ve loaded. The cookie handling seems to be working okay in FF.&lt;br /&gt;Now I&apos;m fining the main code is chugging along on it&apos;s own and looks like it&apos;s finishing execution before the onload routines have even been called. Now to find a way to make the code wait for them.&lt;br /&gt;It&apos;s still working okay with F5 on FF, but Chrome still isn&apos;t seeing the one image&apos;s values from the other image&apos;s routine.&lt;br /&gt;&lt;br /&gt;Okay, using SetTimeout to add a 100ms delay to the execution of the final cookie read seems to have sorted it in FF, but Chrome seems to be acting as if there ain&apos;t no cookie. despite it having been written to by two functions, all the values are undefined. :/&lt;br /&gt;&lt;br /&gt;Is FF tolerating my buggy code, or is Chrome buggy?&lt;br /&gt;&lt;br /&gt;&lt;b&gt;index.html:&lt;/b&gt;&lt;br /&gt;&lt;code&gt;&lt;pre&gt;&amp;lt;!DOCTYPE html&amp;gt;
&amp;lt;html&amp;gt;
 &amp;lt;head&amp;gt;
  &amp;lt;script src= &quot;files/images.js&quot;&amp;gt;&amp;lt;/script&amp;gt;
  &amp;lt;title&amp;gt;&amp;lt;/title&amp;gt;
 &amp;lt;/head&amp;gt;
 &amp;lt;body&amp;gt;
  &amp;lt;div&amp;gt;
   &amp;lt;h1 id=&quot;page_title&quot;&amp;gt;&amp;lt;/h1&amp;gt;
   &amp;lt;p id=&quot;image_init_1&quot;&amp;gt;&amp;lt;/p&amp;gt;
   &amp;lt;p id=&quot;image_init_2&quot;&amp;gt;&amp;lt;/p&amp;gt;
   &amp;lt;p&amp;gt;&amp;lt;/p&amp;gt;
   &amp;lt;p id=&quot;test1&quot;&amp;gt;&amp;lt;/p&amp;gt;
   &amp;lt;p id=&quot;test2&quot;&amp;gt;&amp;lt;/p&amp;gt;
   &amp;lt;p id=&quot;test3&quot;&amp;gt;&amp;lt;/p&amp;gt;
   &amp;lt;p id=&quot;test4&quot;&amp;gt;&amp;lt;/p&amp;gt;
   &amp;lt;p id=&quot;test5&quot;&amp;gt;&amp;lt;/p&amp;gt;
   &amp;lt;p id=&quot;test6&quot;&amp;gt;&amp;lt;/p&amp;gt;
   &amp;lt;p id=&quot;test7&quot;&amp;gt;&amp;lt;/p&amp;gt;
   &amp;lt;p id=&quot;test8&quot;&amp;gt;&amp;lt;/p&amp;gt;
   &amp;lt;p id=&quot;test9&quot;&amp;gt;&amp;lt;/p&amp;gt;
  &amp;lt;/div&amp;gt;
  &amp;lt;div&amp;gt;
   &amp;lt;script&amp;gt;
    init();
    &lt;s&gt;read_cookie();&lt;/s&gt;
   &amp;lt;/script&amp;gt;
  &amp;lt;/div&amp;gt;
 &amp;lt;/body&amp;gt;
&amp;lt;/html&amp;gt;&lt;/pre&gt;&lt;/code&gt;&lt;br /&gt;&lt;br /&gt;&lt;b&gt;/files/images.js:&lt;/b&gt;&lt;br /&gt;&lt;code&gt;&lt;pre&gt;// images.js

	var JS_First_Image= &quot;files/bomb.png&quot;, JS_Second_Image= &quot;files/eye.png&quot;;
	var First_Image_x_1, First_Image_y_1;
	var Second_Image_x_1, Second_Image_y_1;

function First_img() {
// Read the cookie if it&apos;s there.
	var myJSON_1= document.cookie;
	document.getElementById(&quot;test1&quot;).innerHTML= &quot;Read1: &quot;+myJSON_1;
	if (myJSON_1 !== &quot;&quot;) {
    		var myObj_1 = JSON.parse(myJSON_1);
		var First_Image_x_1= myObj_1.First_Image_x_1;
		var First_Image_y_1= myObj_1.First_Image_y_1;
		var Second_Image_x_1= myObj_1.Second_Image_x_1;
		var Second_Image_y_1= myObj_1.Second_Image_y_1;
	}
	if (typeof Second_Image_x_1 === &quot;undefined&quot; &amp;&amp; typeof Second_Image_y_1 === &quot;undefined&quot;) {
		var Second_Image_x_1= 0;
		var Second_Image_y_1= 0;
	}
	document.getElementById(&quot;test2&quot;).innerHTML= &quot;Img1a: &quot;+First_Image_x_1+&quot; &quot;+First_Image_y_1+&quot; &quot;+Second_Image_x_1+&quot; &quot;+Second_Image_y_1;
// Write the cookie
	First_Image_x_1= document.getElementById(&quot;First_one&quot;).naturalWidth;
	First_Image_y_1= document.getElementById(&quot;First_one&quot;).naturalHeight;
	var myObj_1= {First_Image_x_1, First_Image_y_1, Second_Image_x_1, Second_Image_y_1};
	var myJSON_1= JSON.stringify(myObj_1);
	document.cookie= myJSON_1;
	document.getElementById(&quot;test3&quot;).innerHTML= &quot;Img1b: &quot;+First_Image_x_1+&quot; &quot;+First_Image_y_1+&quot; &quot;+Second_Image_x_1+&quot; &quot;+Second_Image_y_1;

}

function Second_img() {
// Read the cookie if it&apos;s there.
	var myJSON_2= document.cookie;
	document.getElementById(&quot;test4&quot;).innerHTML= &quot;Read2: &quot;+myJSON_2;
	if (myJSON_2 !== &quot;&quot;) {
    		var myObj_2 = JSON.parse(myJSON_2);
		var First_Image_x_1= myObj_2.First_Image_x_1;
		var First_Image_y_1= myObj_2.First_Image_y_1;
		var Second_Image_x_1= myObj_2.Second_Image_x_1;
		var Second_Image_y_1= myObj_2.Second_Image_y_1;
	}
	if (typeof First_Image_x_1 === &quot;undefined&quot; &amp;&amp; typeof First_Image_y_1 === &quot;undefined&quot;) {
		var First_Image_x_1= 0;
		var First_Image_y_1= 0;
	}
	document.getElementById(&quot;test5&quot;).innerHTML= &quot;Img2a: &quot;+First_Image_x_1+&quot; &quot;+First_Image_y_1+&quot; &quot;+Second_Image_x_1+&quot; &quot;+Second_Image_y_1;
// Write the cookie
	Second_Image_x_1= document.getElementById(&quot;Second_one&quot;).naturalWidth;
	Second_Image_y_1= document.getElementById(&quot;Second_one&quot;).naturalHeight;
	var myObj_2= {First_Image_x_1, First_Image_y_1, Second_Image_x_1, Second_Image_y_1};
	var myJSON_2= JSON.stringify(myObj_2);
	document.cookie= myJSON_2;
	document.getElementById(&quot;test6&quot;).innerHTML= &quot;Img2b: &quot;+First_Image_x_1+&quot; &quot;+First_Image_y_1+&quot; &quot;+Second_Image_x_1+&quot; &quot;+Second_Image_y_1;
}

function init() {
// Write the first image invisibly, and get it&apos;s size.
	document.getElementById(&quot;image_init_1&quot;).innerHTML= &apos;&amp;lt;img id=&quot;First_one&quot; alt=&quot;Move along&quot; src=&quot;&apos;+JS_First_Image+&apos;&quot; style=&quot;width:0px; height:0px;&quot; onload=&quot;First_img()&quot;&amp;gt;&apos;;
// Write the second image invisibly, and get it&apos;s size.
	document.getElementById(&quot;image_init_2&quot;).innerHTML= &apos;&amp;lt;img id=&quot;Second_one&quot; alt=&quot;Nothing to see&quot; src=&quot;&apos;+JS_Second_Image+&apos;&quot; style=&quot;width:0px; height:0px;&quot; onload=&quot;Second_img()&quot;&amp;gt;&apos;;
	&lt;b&gt;setTimeout(read_cookie, 100);&lt;/b&gt;
}

function read_cookie() {
	document.getElementById(&quot;test7&quot;).innerHTML= &quot;Check3: &quot;+First_Image_x_1+&quot; &quot;+First_Image_y_1+&quot; &quot;+Second_Image_x_1+&quot; &quot;+Second_Image_y_1;
// Read the cookie if it&apos;s there.
	var myJSON_3= document.cookie;
	document.getElementById(&quot;test8&quot;).innerHTML= &quot;Read3a: &quot;+myJSON_3;
	if (myJSON_3 !== &quot;&quot;) {
    		var myObj_3 = JSON.parse(myJSON_3);
		var First_Image_x_1= myObj_3.First_Image_x_1;
		var First_Image_y_1= myObj_3.First_Image_y_1;
		var Second_Image_x_1= myObj_3.Second_Image_x_1;
		var Second_Image_y_1= myObj_3.Second_Image_y_1;
	}
	document.getElementById(&quot;test9&quot;).innerHTML= &quot;Read3b: &quot;+First_Image_x_1+&quot; &quot;+First_Image_y_1+&quot; &quot;+Second_Image_x_1+&quot; &quot;+Second_Image_y_1;
}&lt;/pre&gt;&lt;/code&gt;&lt;br /&gt;&lt;br /&gt;&lt;b&gt;/files/bomb.png:&lt;/b&gt;&lt;br /&gt;&lt;img src=&quot;https://tornir.dreamwidth.org/file/42948.png&quot; alt=&quot;bomb.png&quot; title=&quot;bomb.png&quot; /&gt;&lt;br /&gt;&lt;br /&gt;&lt;b&gt;/files/eye.png&lt;/b&gt;:&lt;br /&gt;&lt;img src=&quot;https://tornir.dreamwidth.org/file/43046.png&quot; alt=&quot;eye.png&quot; title=&quot;eye.png&quot; /&gt;&lt;br /&gt;&lt;br /&gt;&lt;img src=&quot;https://www.dreamwidth.org/tools/commentcount?user=javascript&amp;ditemid=1162&quot; width=&quot;30&quot; height=&quot;12&quot; alt=&quot;comment count unavailable&quot; style=&quot;vertical-align: middle;&quot;/&gt; comments</description>
  <comments>https://javascript.dreamwidth.org/1162.html</comments>
  <lj:security>public</lj:security>
  <lj:poster>tornir</lj:poster>
  <lj:reply-count>6</lj:reply-count>
</item>
<item>
  <guid isPermaLink='true'>https://javascript.dreamwidth.org/857.html</guid>
  <pubDate>Thu, 07 Apr 2011 21:12:19 GMT</pubDate>
  <title>JIT: JavaScript InfoVis Toolkit</title>
  <link>https://javascript.dreamwidth.org/857.html</link>
  <description>Posted by: &lt;span lj:user=&apos;foxfirefey&apos; style=&apos;white-space: nowrap;&apos; class=&apos;ljuser&apos;&gt;&lt;a href=&apos;https://foxfirefey.dreamwidth.org/profile&apos;&gt;&lt;img src=&apos;https://www.dreamwidth.org/img/silk/identity/user.png&apos; alt=&apos;[personal profile] &apos; width=&apos;17&apos; height=&apos;17&apos; style=&apos;vertical-align: text-bottom; border: 0; padding-right: 1px;&apos; /&gt;&lt;/a&gt;&lt;a href=&apos;https://foxfirefey.dreamwidth.org/&apos;&gt;&lt;b&gt;foxfirefey&lt;/b&gt;&lt;/a&gt;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;a href=&quot;http://thejit.org/&quot;&gt;Pretty graphs!&lt;/a&gt;

Many other &lt;a href=&quot;http://www.smashingmagazine.com/2011/04/07/useful-javascript-and-jquery-tools-libraries-plugins/&quot;&gt;fun JS libraries/tools here&lt;/a&gt;.&lt;br /&gt;&lt;br /&gt;&lt;img src=&quot;https://www.dreamwidth.org/tools/commentcount?user=javascript&amp;ditemid=857&quot; width=&quot;30&quot; height=&quot;12&quot; alt=&quot;comment count unavailable&quot; style=&quot;vertical-align: middle;&quot;/&gt; comments</description>
  <comments>https://javascript.dreamwidth.org/857.html</comments>
  <lj:security>public</lj:security>
  <lj:poster>foxfirefey</lj:poster>
  <lj:reply-count>1</lj:reply-count>
</item>
<item>
  <guid isPermaLink='true'>https://javascript.dreamwidth.org/727.html</guid>
  <pubDate>Sun, 16 May 2010 13:12:30 GMT</pubDate>
  <title>jsFiddle: easy way to play with JS frameworks and share code snippets </title>
  <link>https://javascript.dreamwidth.org/727.html</link>
  <description>Posted by: &lt;span lj:user=&apos;afuna&apos; style=&apos;white-space: nowrap;&apos; class=&apos;ljuser&apos;&gt;&lt;a href=&apos;https://afuna.dreamwidth.org/profile&apos;&gt;&lt;img src=&apos;https://www.dreamwidth.org/img/silk/identity/user.png&apos; alt=&apos;[personal profile] &apos; width=&apos;17&apos; height=&apos;17&apos; style=&apos;vertical-align: text-bottom; border: 0; padding-right: 1px;&apos; /&gt;&lt;/a&gt;&lt;a href=&apos;https://afuna.dreamwidth.org/&apos;&gt;&lt;b&gt;afuna&lt;/b&gt;&lt;/a&gt;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;a href=&quot;http://jsfiddle.net/&quot;&gt;jsFiddle&lt;/a&gt; is a nifty website which combines pastebin with a working dev environment. It&apos;s handy for fiddling about with code snippets, or for putting up code for a demo when asking a question.&lt;br /&gt;&lt;br /&gt;You provide the HTML, JS, and any CSS, select a framework to be made available, then click the &quot;Run&quot; button to see your results. Then you can clear everything, or else save the code snippets and be given a URL to access them from.&lt;br /&gt;&lt;br /&gt;Also nifty: you can simulate AJAX requests.&lt;br /&gt;&lt;br /&gt;Overall, it takes out some of the pain of setting up a test case or quick discardable demo when sharing ideas with other people.&lt;br /&gt;&lt;br /&gt;&lt;img src=&quot;https://www.dreamwidth.org/tools/commentcount?user=javascript&amp;ditemid=727&quot; width=&quot;30&quot; height=&quot;12&quot; alt=&quot;comment count unavailable&quot; style=&quot;vertical-align: middle;&quot;/&gt; comments</description>
  <comments>https://javascript.dreamwidth.org/727.html</comments>
  <lj:security>public</lj:security>
  <lj:poster>afuna</lj:poster>
  <lj:reply-count>2</lj:reply-count>
</item>
<item>
  <guid isPermaLink='true'>https://javascript.dreamwidth.org/489.html</guid>
  <pubDate>Sat, 08 May 2010 15:01:34 GMT</pubDate>
  <link>https://javascript.dreamwidth.org/489.html</link>
  <description>Posted by: &lt;span lj:user=&apos;erda&apos; style=&apos;white-space: nowrap;&apos; class=&apos;ljuser&apos;&gt;&lt;a href=&apos;https://erda.dreamwidth.org/profile&apos;&gt;&lt;img src=&apos;https://www.dreamwidth.org/img/silk/identity/user.png&apos; alt=&apos;[personal profile] &apos; width=&apos;17&apos; height=&apos;17&apos; style=&apos;vertical-align: text-bottom; border: 0; padding-right: 1px;&apos; /&gt;&lt;/a&gt;&lt;a href=&apos;https://erda.dreamwidth.org/&apos;&gt;&lt;b&gt;erda&lt;/b&gt;&lt;/a&gt;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;I&apos;m curious to know how much javascript knowledge you all have. I&apos;m about 170 pages into my Javascript Beginner&apos;s guide, so I know, um, not much.&lt;br /&gt;&lt;br /&gt;&lt;img src=&quot;https://www.dreamwidth.org/tools/commentcount?user=javascript&amp;ditemid=489&quot; width=&quot;30&quot; height=&quot;12&quot; alt=&quot;comment count unavailable&quot; style=&quot;vertical-align: middle;&quot;/&gt; comments</description>
  <comments>https://javascript.dreamwidth.org/489.html</comments>
  <lj:security>public</lj:security>
  <lj:poster>erda</lj:poster>
  <lj:reply-count>5</lj:reply-count>
</item>
</channel>
</rss>
