<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Just Another Dang Blog &#187; Javascript</title>
	<atom:link href="http://blog.lopau.com/category/javascript/feed/" rel="self" type="application/rss+xml" />
	<link>http://blog.lopau.com</link>
	<description>A tech blog about web development, graphic designs, freelancing, cloud computing, mobile development, innovations and seo.</description>
	<lastBuildDate>Thu, 06 Oct 2011 03:01:41 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
		<item>
		<title>Adding Server Preview Plugin on CKEditor 3.x version</title>
		<link>http://blog.lopau.com/adding-server-preview-plugin-on-ckeditor-3-x-version/</link>
		<comments>http://blog.lopau.com/adding-server-preview-plugin-on-ckeditor-3-x-version/#comments</comments>
		<pubDate>Wed, 29 Jun 2011 16:52:56 +0000</pubDate>
		<dc:creator>lopau</dc:creator>
				<category><![CDATA[Javascript]]></category>

		<guid isPermaLink="false">http://blog.lopau.com/?p=1281</guid>
		<description><![CDATA[If you were using the older FCKEditor online editor and got the Server Preview plugin working, you should know that the same plugin is not compatible with CKEditor. What Server Preview does is it allows you to preview content on a custom designed page you have be it an HTML, PHP or ASP page, giving [...]]]></description>
			<content:encoded><![CDATA[<p>If you were using the older FCKEditor online editor and got the Server Preview plugin working, you should know that the same plugin is not compatible with CKEditor.  What Server Preview does is it allows you to preview content on a custom  designed page you have be it an HTML, PHP or ASP page, giving you an idea how the page would look like with the content you are entering. </p>
<p>After scorching the net for on how to have Server Preview plugin work on CKEDitor some were a bit confusing, luckily somebody(<a href="http://dev.ckeditor.com/ticket/6251">vladfr</a>) ported the script to work with CKEditor but he has no blog or site to document how it works I decided to create a straightforward tutorial on how to get Server Preview enabled on CKEditor.</p>
<p>
<!-- Begin Google Adsense code -->
<div class="googleads">
<script type="text/javascript"><!--
google_ad_client = "pub-4515932012590505";
/* 200x200, created 10/29/08 */
google_ad_slot = "3929428513";
google_ad_width = 200;
google_ad_height = 200;
//-->
</script>
<script type="text/javascript"
src="http://pagead2.googlesyndication.com/pagead/show_ads.js">
</script>
</div>
<!-- End Google Adsense code -->
<br />
<span id="more-1281"></span></p>
<p>1. First ofcourse you should get the latest version of <a href="http://ckeditor.com/">CKEditor</a>.</p>
<p>2. Copy and paste this code and save as plugin.js</p>
<div class="codesnip-container" >
<div class="php codesnip" style="font-family:monospace;"><span class="co4">/**<br />
* File Name: serverpreview\plugin.js<br />
* <br />
* Licensed under the terms of the GNU Lesser General Public License:<br />
* &nbsp; &nbsp; &nbsp; http://www.opensource.org/licenses/lgpl-license.php<br />
* <br />
* &nbsp; &nbsp;Plugin for CKeditor 3 to send the current data to the server so it can be previewed in a custom way<br />
* &nbsp; Extended from the FCK plugin with the same name, by Alfonso Martínez de Lizarrondo<br />
*<br />
* &nbsp;version<br />
* &nbsp; &nbsp; &nbsp;0.1 15/02/2006<br />
* &nbsp; &nbsp; &nbsp;0.2 02/09/2007 Replace the &#8216;Preview&#8217; command instead of creating a custom one.<br />
* &nbsp; &nbsp; &nbsp;0.3 14/07/2010 No longer replaces the Preview button, adds another one instead. &nbsp; &nbsp; &nbsp;<br />
* <br />
* File Author:<br />
* &nbsp; &nbsp; &nbsp; Vlad Fratila<br />
* &nbsp; &nbsp; &nbsp; vlad.fratila@gmail.com<br />
* <br />
* == How to Use: ==<br />
*<br />
* Add the plugin in your config.js like other plugins:<br />
* &nbsp; &nbsp;config.extraPlugins = &#8216;serverpreview&#8217;;<br />
* &nbsp; &nbsp;<br />
* You will also need to specify the full URL of your server-side script like this:<br />
* &nbsp; &nbsp; &nbsp;config.serverPreviewURL = &#8216;http://www.mydomain.com/myfile.php&#8217;;<br />
* In this file, you need to stripslashes and display the post variable &quot;htmlData&quot;<br />
* <br />
* To get an icon for the button, you will need to change your skin&#8217;s CSS file<br />
* (e.g. if you&#8217;re using the default: change /ckeditor/skins/kama/editor.css)<br />
* I just disabled the Preview plugin and did a Search/Replace to replace &#8216;preview&#8217; with &#8216;serverpreview&#8217;.<br />
* <br />
* &nbsp;Lastly, don&#8217;t forget to add the button &#8216;ServerPreview&#8217; to your toolbars!<br />
*<br />
*/</span></p>
<p>
<span class="br0">&#40;</span><span class="kw2">function</span><span class="br0">&#40;</span><span class="br0">&#41;</span><span class="br0">&#123;</span><br />
&nbsp; &nbsp;<br />
&nbsp; &nbsp;<span class="kw2">var</span> pluginName <span class="sy0">=</span> <span class="st_h">&#8216;serverpreview&#8217;</span><span class="sy0">;</span></p>
<p>&nbsp; &nbsp;<span class="kw2">var</span> serverpreviewCmd <span class="sy0">=</span><br />
&nbsp; &nbsp;<span class="br0">&#123;</span><br />
&nbsp; &nbsp; &nbsp; modes <span class="sy0">:</span> <span class="br0">&#123;</span> wysiwyg<span class="sy0">:</span>1<span class="sy0">,</span> source<span class="sy0">:</span>1 <span class="br0">&#125;</span><span class="sy0">,</span><br />
&nbsp; &nbsp; &nbsp; canUndo <span class="sy0">:</span> <span class="kw4">false</span><span class="sy0">,</span><br />
&nbsp; &nbsp; &nbsp; <a href="http://www.php.net/exec"><span class="kw3">exec</span></a> <span class="sy0">:</span> <span class="kw2">function</span><span class="br0">&#40;</span> editor <span class="br0">&#41;</span><br />
&nbsp; &nbsp; &nbsp; <span class="br0">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span class="kw2">var</span> theForm <span class="sy0">=</span> document<span class="sy0">.</span>getElementById<span class="br0">&#40;</span><span class="st_h">&#8216;serverPreviewForm&#8217;</span><span class="br0">&#41;</span> <span class="sy0">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span class="kw1">if</span> <span class="br0">&#40;</span><span class="sy0">!</span>theForm<span class="br0">&#41;</span> <span class="br0">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="co1">//it doesn&#8217;t exist still, we create it here</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; theForm <span class="sy0">=</span> document<span class="sy0">.</span>createElement<span class="br0">&#40;</span><span class="st_h">&#8216;FORM&#8217;</span><span class="br0">&#41;</span> <span class="sy0">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; theForm<span class="sy0">.</span>method <span class="sy0">=</span> <span class="st_h">&#8216;POST&#8217;</span> <span class="sy0">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; theForm<span class="sy0">.</span>name <span class="sy0">=</span> <span class="st_h">&#8216;serverPreviewForm&#8217;</span> <span class="sy0">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; theForm<span class="sy0">.</span>id<span class="sy0">=</span>theForm<span class="sy0">.</span>name <span class="sy0">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; theForm<span class="sy0">.</span>style<span class="sy0">.</span>display <span class="sy0">=</span> <span class="st_h">&#8216;none&#8217;</span> <span class="sy0">;</span></p>
<p>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; theForm<span class="sy0">.</span>action <span class="sy0">=</span> editor<span class="sy0">.</span>config<span class="sy0">.</span>serverPreviewURL<span class="sy0">;</span></p>
<p>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="co1">//new window please</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; theForm<span class="sy0">.</span>target<span class="sy0">=</span><span class="st_h">&#8216;_blank&#8217;</span><span class="sy0">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; document<span class="sy0">.</span>body<span class="sy0">.</span>appendChild<span class="br0">&#40;</span> theForm <span class="br0">&#41;</span><span class="sy0">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span class="br0">&#125;</span></p>
<p>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span class="co1">//clear previous data</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;theForm<span class="sy0">.</span>innerHTML <span class="sy0">=</span> <span class="st_h">&#8221;</span> <span class="sy0">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span class="co1">//set the new content</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span class="kw2">var</span> input <span class="sy0">=</span> document<span class="sy0">.</span>createElement<span class="br0">&#40;</span><span class="st_h">&#8216;INPUT&#8217;</span><span class="br0">&#41;</span> <span class="sy0">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;input<span class="sy0">.</span>type <span class="sy0">=</span> <span class="st_h">&#8216;hidden&#8217;</span><span class="sy0">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span class="co1">//change the name as needed &#8211;&gt;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;input<span class="sy0">.</span>name <span class="sy0">=</span> <span class="st_h">&#8216;htmlData&#8217;</span> <span class="sy0">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span class="co1">//set the data</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;input<span class="sy0">.</span>value <span class="sy0">=</span> editor<span class="sy0">.</span>getData<span class="br0">&#40;</span><span class="br0">&#41;</span><span class="sy0">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span class="co1">//append the new input to the form</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;theForm<span class="sy0">.</span>appendChild<span class="br0">&#40;</span> input <span class="br0">&#41;</span><span class="sy0">;</span></p>
<p>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span class="co1">//that&#8217;s all, append additional fields as needed, or set the variables in the previewPath</span></p>
<p>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span class="co1">//send the data to the server</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;theForm<span class="sy0">.</span>submit<span class="br0">&#40;</span><span class="br0">&#41;</span><span class="sy0">;</span><br />
&nbsp; &nbsp; &nbsp; <span class="br0">&#125;</span><br />
&nbsp; &nbsp;<span class="br0">&#125;</span><br />
&nbsp; &nbsp;<br />
&nbsp; &nbsp;<br />
&nbsp; &nbsp;CKEDITOR<span class="sy0">.</span>plugins<span class="sy0">.</span>add<span class="br0">&#40;</span> pluginName<span class="sy0">,</span><br />
&nbsp; &nbsp;<span class="br0">&#123;</span><br />
&nbsp; &nbsp; &nbsp; init <span class="sy0">:</span> <span class="kw2">function</span><span class="br0">&#40;</span> editor <span class="br0">&#41;</span><br />
&nbsp; &nbsp; &nbsp; <span class="br0">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;editor<span class="sy0">.</span>addCommand<span class="br0">&#40;</span> pluginName<span class="sy0">,</span> serverpreviewCmd <span class="br0">&#41;</span><span class="sy0">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;editor<span class="sy0">.</span>ui<span class="sy0">.</span>addButton<span class="br0">&#40;</span> <span class="st_h">&#8216;ServerPreview&#8217;</span><span class="sy0">,</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="br0">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;label <span class="sy0">:</span> <span class="st_h">&#8216;Server Preview&#8217;</span><span class="sy0">,</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;command <span class="sy0">:</span> pluginName<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="br0">&#125;</span><span class="br0">&#41;</span><span class="sy0">;</span><br />
&nbsp; &nbsp; &nbsp; <span class="br0">&#125;</span><br />
&nbsp; &nbsp;<span class="br0">&#125;</span><span class="br0">&#41;</span><span class="sy0">;</span><br />
&nbsp; &nbsp;<br />
<span class="br0">&#125;</span><span class="br0">&#41;</span><span class="br0">&#40;</span><span class="br0">&#41;</span><span class="sy0">;</span></div>
</div>
<p>3. Create a serverpreview folder in your CKEditor plugins folder</p>
<p>4. Move the saved plugin.js to this folder</p>
<p>5. Open the ckeditor/config.js file and add the following, briefly explaining the serverPreviewURL is the path to the custom template page. Toolbar with ServerPreview overrides the old Preview button.</p>
<div class="codesnip-container" >
<div class="php codesnip" style="font-family:monospace;">config<span class="sy0">.</span>extraPlugins <span class="sy0">=</span> <span class="st_h">&#8216;serverpreview&#8217;</span><span class="sy0">;</span><br />
config<span class="sy0">.</span>serverPreviewURL <span class="sy0">=</span> <span class="st_h">&#8216;http://localhost/ckeditor/preview.php&#8217;</span><span class="sy0">;</span><br />
config<span class="sy0">.</span>toolbar <span class="sy0">=</span> <span class="br0">&#91;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="br0">&#91;</span><span class="st_h">&#8216;Source&#8217;</span><span class="br0">&#93;</span><span class="sy0">,</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="br0">&#91;</span><span class="st_h">&#8216;ServerPreview&#8217;</span><span class="br0">&#93;</span><span class="sy0">,</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="br0">&#91;</span> <span class="st_h">&#8216;Styles&#8217;</span><span class="sy0">,</span><span class="st_h">&#8216;Format&#8217;</span><span class="sy0">,</span><span class="st_h">&#8216;TextColor&#8217;</span><span class="sy0">,</span><span class="st_h">&#8216;BGColor&#8217;</span><span class="sy0">,</span> <span class="st_h">&#8216;Link&#8217;</span><span class="sy0">,</span><span class="st_h">&#8216;Unlink&#8217;</span><span class="sy0">,</span><span class="st_h">&#8216;Anchor&#8217;</span> <span class="br0">&#93;</span><span class="sy0">,</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="br0">&#91;</span><span class="st_h">&#8216;Cut&#8217;</span><span class="sy0">,</span><span class="st_h">&#8216;Copy&#8217;</span><span class="sy0">,</span><span class="st_h">&#8216;Paste&#8217;</span><span class="sy0">,</span><span class="st_h">&#8216;Undo&#8217;</span><span class="sy0">,</span><span class="st_h">&#8216;Redo&#8217;</span> <span class="br0">&#93;</span><span class="sy0">,</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="br0">&#91;</span><span class="st_h">&#8216;Bold&#8217;</span><span class="sy0">,</span> <span class="st_h">&#8216;Italic&#8217;</span><span class="br0">&#93;</span><span class="sy0">,</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="br0">&#91;</span> <span class="st_h">&#8216;Image&#8217;</span><span class="sy0">,</span><span class="st_h">&#8216;Flash&#8217;</span><span class="sy0">,</span><span class="st_h">&#8216;Table&#8217;</span><span class="sy0">,</span><span class="st_h">&#8216;HorizontalRule&#8217;</span><span class="sy0">,</span><span class="st_h">&#8216;Smiley&#8217;</span><span class="sy0">,</span><span class="st_h">&#8216;SpecialChar&#8217;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="br0">&#93;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="br0">&#93;</span><span class="sy0">;</span></div>
</div>
<p>6. Create a preview.php file and save on the serverPreviewURL location. Below is the simple custom template in php.</p>
<div class="codesnip-container" >
<div class="php codesnip" style="font-family:monospace;">&lt; !doctype html&gt;<br />
&lt;html&gt;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &lt;head&gt;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &lt;title&gt;FCKeditor &#8211; Server preview&lt;/title&gt;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &lt;meta charset=&quot;utf-8&quot;&gt;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &lt;/meta&gt;&lt;/head&gt;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &lt;body&gt;<br />
<span class="kw2">&lt;?php</span></p>
<p>&nbsp; &nbsp; &nbsp; &nbsp; <span class="re0">$data</span> <span class="sy0">=</span> <span class="re0">$_POST</span><span class="br0">&#91;</span><span class="st_h">&#8216;htmlData&#8217;</span><span class="br0">&#93;</span><span class="sy0">;</span></p>
<p>&nbsp; &nbsp; &nbsp; &nbsp; <span class="kw1">if</span> <span class="br0">&#40;</span> <a href="http://www.php.net/get_magic_quotes_gpc"><span class="kw3">get_magic_quotes_gpc</span></a><span class="br0">&#40;</span><span class="br0">&#41;</span> <span class="br0">&#41;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="re0">$data</span> <span class="sy0">=</span> <a href="http://www.php.net/stripslashes"><span class="kw3">stripslashes</span></a><span class="br0">&#40;</span> <span class="re0">$data</span> <span class="br0">&#41;</span> <span class="sy0">;</span></p>
<p>&nbsp; &nbsp; &nbsp; &nbsp; <span class="kw1">echo</span> <span class="re0">$data</span> <span class="sy0">;</span><br />
<span class="sy1">?&gt;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &lt;/body&gt;<br />
&lt;/html&gt;</div>
</div>
<p>7. Next open ckeditor/skins/kama/editor.css search for .cke_button_preview and change to .cke_button_serverpreview then save.</p>
<p>8. And here is a page I put for a working <a href="http://lopau.com/ckeditor/"><strong>DEMO </strong></a>.</p>
<p>Enjoy</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.lopau.com/adding-server-preview-plugin-on-ckeditor-3-x-version/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Ajax caching issue with IE workaround</title>
		<link>http://blog.lopau.com/ajax-caching-issue-with-ie-workaround/</link>
		<comments>http://blog.lopau.com/ajax-caching-issue-with-ie-workaround/#comments</comments>
		<pubDate>Sun, 25 Oct 2009 04:15:10 +0000</pubDate>
		<dc:creator>lopau</dc:creator>
				<category><![CDATA[Javascript]]></category>

		<guid isPermaLink="false">http://blog.lopau.com/?p=741</guid>
		<description><![CDATA[If you&#8217;ve been developing websites I&#8217;m sure you pretty feel a little nausea from browser refreshing after an operation and prefer to work with AJAX for updating, deleting or loading some data from your DB with out the page reloading. Most commonly used is http request is GET, your script runs flawlessly with Firefox, Chrome [...]]]></description>
			<content:encoded><![CDATA[<p>If you&#8217;ve been developing websites I&#8217;m sure you pretty feel a little  nausea from browser refreshing after an operation and prefer to work with AJAX for updating, deleting or loading some data from your DB with out the page reloading.</p>
<p>Most commonly used is http request is GET, your script runs flawlessly with Firefox, Chrome and Safari however on IE7 &amp; and IE8 you don&#8217;t see the updates. This is because IE 7 and IE 8 treat GET request differently than POST, if there is no change from the last call it will always load up from it&#8217;s cache.</p>
<p>The workaround to the issue is pass an ever changing variable to the GET request like the current timestamp or date.</p>
<p>1. You can pass it on the ajax function call by adding an extra parameter time on the ajax call on the page.</p>
<blockquote><p>ajaxify(x,&lt;?php echo time(); ?&gt;);<span style="white-space: pre;"> // ajaxify(keywords, rand_time)</span></p></blockquote>
<p>Then on your ajax function xmlHttp request call the rand_time parameter</p>
<blockquote><p><span style="white-space: pre;"><span style="white-space: normal; ">xmlHttp.open(&#8220;GET&#8221;,&#8221;includes/ajax_page.php?dontcacheme=&#8221; + rand_time +&#8221;&amp;keywords=&#8221;+keywords,true);</span></span></p></blockquote>
<p>2. Or just create the random string using a Javascript Date class.</p>
<blockquote><p><span style="white-space: pre; "><span style="white-space: normal; "> xmlHttp.open(&#8220;GET&#8221;,&#8221;includes/ajax_page.php?dontcacheme=&#8221; + new Date().getTime() +&#8221;&amp;keywords=&#8221;+keywords,true);</span></span></p></blockquote>
<p>This workaround worked well with my ajax scripts. Hope it helps.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.lopau.com/ajax-caching-issue-with-ie-workaround/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>3D CSS Effects &#8211; Javascript and CSS on Steriods</title>
		<link>http://blog.lopau.com/3d-css-effects-javascript-and-css-on-steriods/</link>
		<comments>http://blog.lopau.com/3d-css-effects-javascript-and-css-on-steriods/#comments</comments>
		<pubDate>Tue, 21 Jul 2009 03:34:53 +0000</pubDate>
		<dc:creator>lopau</dc:creator>
				<category><![CDATA[Browsers]]></category>
		<category><![CDATA[CSS]]></category>
		<category><![CDATA[Javascript]]></category>

		<guid isPermaLink="false">http://blog.lopau.com/?p=612</guid>
		<description><![CDATA[Wish I have a new Mac already to try this on Safari with Webkit. This is an example of Javascript and CSS taking it heads on with Flash, like Javascript and CSS on steriods. On Windows with Safari 4.1 with latest Webkit build you won&#8217;t see the 3D effect but you would see the nice [...]]]></description>
			<content:encoded><![CDATA[<p>Wish I have a new Mac already to try this on Safari with Webkit. This is an example of Javascript and CSS taking it heads on with Flash, like Javascript and CSS on steriods. On Windows with <a href="http://www.apple.com/safari/download/">Safari 4.1</a> with latest <a href="http://nightly.webkit.org/">Webkit</a> build you won&#8217;t see the 3D effect but you would see the nice stacking of the images, controlling the scroll with your arrow keys. For Mac users on Snow Leopard you got to try this out. Go to <a href="http://www.satine.org/research/webkit/snowleopard/snowstack.html">Snowstack</a> to experience it on your Safari browser. Watch the video.</p>
<div class="codesnip-container" ><object width="425" height="344"><param name="movie" value="http://www.youtube.com/v/3R6sb4NO25E&#038;hl=en&#038;fs=1&#038;"></param><param name="allowFullScreen" value="true"></param><param name="allowscriptaccess" value="always"></param><embed src="http://www.youtube.com/v/3R6sb4NO25E&#038;hl=en&#038;fs=1&#038;" type="application/x-shockwave-flash" allowscriptaccess="always" allowfullscreen="true" width="425" height="344"></embed></object></div>
]]></content:encoded>
			<wfw:commentRss>http://blog.lopau.com/3d-css-effects-javascript-and-css-on-steriods/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Submit a Form using Enter Key</title>
		<link>http://blog.lopau.com/submit-a-form-using-enter-key/</link>
		<comments>http://blog.lopau.com/submit-a-form-using-enter-key/#comments</comments>
		<pubDate>Mon, 23 Feb 2009 11:54:37 +0000</pubDate>
		<dc:creator>lopau</dc:creator>
				<category><![CDATA[Javascript]]></category>

		<guid isPermaLink="false">http://blog.lopau.com/?p=430</guid>
		<description><![CDATA[Here is a little Javascript I picked up. I run into a problem in IE wherein a form won&#8217;t submit when you hit the Enter key it just reloads itself but clicking the Submit button would processes your form. The form works with the Enter key fine in FF but not in IE. Chances are [...]]]></description>
			<content:encoded><![CDATA[<p>Here is a little Javascript I picked up. I run into a problem in IE wherein a form won&#8217;t submit when you hit the Enter key it just reloads itself but clicking the Submit button would processes your form. The form works with the Enter key fine in FF but not in IE.</p>
<p>Chances are that you maybe calling a function on your Submit button that will load the requested page? Something like this?</p>
<blockquote><p>input type=&#8221;submit&#8221; name=&#8221;search&#8221; value=&#8221;Search&#8221; onClick=&#8221;myfunction();&#8221; > </p></blockquote>
<p>Where in the myfunction() function can be anything like validating a page before it submits your data, or trigger another event or load an ajax request.</p>
<p>To fix this and allow using the Enter key to submit your form in IE. Create a new function in your Javascript like below which checks for the Enter key being pressed, keyCode == 13 then call your original event myfunction.</p>
<blockquote><p>
	function checkEnter(e){<br />
        var characterCode<br />
    if(e &#038;&#038; e.which){<br />
        e = e<br />
        characterCode = e.which<br />
     }<br />
    else {<br />
        e = event<br />
        characterCode = e.keyCode<br />
    }</p>
<p>    if(characterCode == 13){<br />
		myfunction(); // onClick function you were loading on the submit button<br />
        return false<br />
    }<br />
    else{<br />
        return true<br />
    }<br />
    } // checkEnter
</p></blockquote>
<p>Then on one of the input fields call the onKeyPress event and call your new function.</p>
<blockquote><p>input type=&#8221;text&#8221; name=&#8221;keywords&#8221;  onKeyPress=&#8221;return checkEnter(event)&#8221; > </p></blockquote>
<p>
<!-- Begin Google Adsense code -->
<div class="googleads">
<script type="text/javascript"><!--
google_ad_client = "pub-4515932012590505";
/* 200x200, created 10/29/08 */
google_ad_slot = "3929428513";
google_ad_width = 200;
google_ad_height = 200;
//-->
</script>
<script type="text/javascript"
src="http://pagead2.googlesyndication.com/pagead/show_ads.js">
</script>
</div>
<!-- End Google Adsense code -->
</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.lopau.com/submit-a-form-using-enter-key/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

