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

<rss version="2.0" 
   xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
   xmlns:admin="http://webns.net/mvcb/"
   xmlns:dc="http://purl.org/dc/elements/1.1/"
   xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
   xmlns:wfw="http://wellformedweb.org/CommentAPI/"
   xmlns:content="http://purl.org/rss/1.0/modules/content/"
   >
<channel>
    <title>Webconsults Europe Consulting in PHP  Databases AJAX SEO WEB 20 Webdevelopment - JavaScript</title>
    <link>http://webconsults.eu/</link>
    <description>PHP AJAX OOP SEO Training MySQL WEB 2 0 JSON Security OOP</description>
    <dc:language>en</dc:language>
    <generator>Serendipity 1.5.1 - http://www.s9y.org/</generator>
    <pubDate>Tue, 02 Sep 2008 13:35:19 GMT</pubDate>

    <image>
        <url>http://webconsults.eu/templates/default/img/s9y_banner_small.png</url>
        <title>RSS: Webconsults Europe Consulting in PHP  Databases AJAX SEO WEB 20 Webdevelopment - JavaScript - PHP AJAX OOP SEO Training MySQL WEB 2 0 JSON Security OOP</title>
        <link>http://webconsults.eu/</link>
        <width>100</width>
        <height>21</height>
    </image>

<item>
    <title>Overlying DIV</title>
    <link>http://webconsults.eu/archives/20-Overlying-DIV.html</link>
            <category>JavaScript</category>
    
    <comments>http://webconsults.eu/archives/20-Overlying-DIV.html#comments</comments>
    <wfw:comment>http://webconsults.eu/wfwcomment.php?cid=20</wfw:comment>

    <slash:comments>2</slash:comments>
    <wfw:commentRss>http://webconsults.eu/rss.php?version=2.0&amp;type=comments&amp;cid=20</wfw:commentRss>
    

    <author>nospam@example.com (John Behrens)</author>
    <content:encoded>
    Just a simple JavaScript example how to display a overlying div on the whole page which is blocking all underlying links and forms and also handles problems with selectboxes in IE Browsers. Sometimes it is neccesary if you wan´t to prevent the user clicking around on the site example during an html loading process. 
Sometimes it can be more usefull to only put it on a part of the site so the user can still access main site navigation.



&lt;div class=&quot;php&quot; style=&quot;text-align: left&quot;&gt;&lt;br /&gt;&amp;lt;div id=&lt;span style=&quot;color: #ff0000;&quot;&gt;&quot;overlyingdiv&quot;&lt;/span&gt; style=&lt;span style=&quot;color: #ff0000;&quot;&gt;&quot;visibility: hidden; position: absolute; top: 0px; left: 0px; width: 100%; height: 100%; filter:alpha(opacity=50); -moz-opacity: 0.50; background-color: #999999; text-align: center;&quot;&lt;/span&gt;&amp;gt;&lt;br /&gt;&amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160;&amp;#160; &amp;lt;iframe width=&lt;span style=&quot;color: #ff0000;&quot;&gt;&quot;100%&quot;&lt;/span&gt; height=&lt;span style=&quot;color: #ff0000;&quot;&gt;&quot;100%&quot;&lt;/span&gt; style=&lt;span style=&quot;color: #ff0000;&quot;&gt;&quot;background-color:transparent;&quot;&lt;/span&gt;&amp;gt;&amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160;&amp;#160; &lt;br /&gt;&amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160;&amp;#160; &amp;lt;/iframe&amp;gt; &lt;br /&gt;&amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160;&amp;#160; &amp;lt;div style=&lt;span style=&quot;color: #ff0000;&quot;&gt;&quot;position: absolute; top: 0px; left: 0px; width: 100%; height: 100%; filter:alpha(opacity=50); -moz-opacity: 0.50; background-color: #999999; text-align: center;&quot;&lt;/span&gt;&amp;gt;&lt;br /&gt;&amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160;&amp;#160; &amp;#160; &amp;#160;&amp;lt;div style=&lt;span style=&quot;color: #ff0000;&quot;&gt;&quot;display:block; margin:0 auto; position:absolute; top: 50%; left:50%;&quot;&lt;/span&gt;&amp;gt;&amp;lt;img src=&lt;span style=&quot;color: #ff0000;&quot;&gt;&quot;loader.giff&quot;&lt;/span&gt; alt=&lt;span style=&quot;color: #ff0000;&quot;&gt;&quot;&quot;&lt;/span&gt;&amp;#160; /&amp;gt;&amp;lt;br /&amp;gt; Loading Data...&amp;lt;/div&amp;gt;&lt;br /&gt;&amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160;&amp;#160; &amp;lt;/div&amp;gt;&lt;br /&gt;&amp;#160; &amp;#160;&amp;#160; &amp;#160; &amp;#160;&amp;#160; &amp;#160; &amp;#160;&amp;#160; &lt;br /&gt;&amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160;&amp;#160; &amp;lt;/div&amp;gt;&lt;span style=&quot;color: #ff0000;&quot;&gt;&#039;&lt;br /&gt;&amp;#160;&lt;/span&gt;&lt;/div&gt;

Java Script Example using prototype 
&lt;div class=&quot;javascript&quot; style=&quot;text-align: left&quot;&gt;&lt;br /&gt;&amp;#160; &amp;#160; &amp;#160; &amp;#160; &lt;span style=&quot;color: #003366; font-weight: bold;&quot;&gt;function&lt;/span&gt; l&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#123;&lt;/span&gt;&amp;#160; &amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&lt;br /&gt;&amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; $&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #3366CC;&quot;&gt;&#039;overlyingdiv&#039;&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#41;&lt;/span&gt;.&lt;span style=&quot;color: #006600;&quot;&gt;style&lt;/span&gt;.&lt;span style=&quot;color: #006600;&quot;&gt;visibility&lt;/span&gt;=&lt;span style=&quot;color: #3366CC;&quot;&gt;&#039;visible&#039;&lt;/span&gt;;&lt;br /&gt;&amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#125;&lt;/span&gt;&lt;br /&gt;&amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &lt;span style=&quot;color: #003366; font-weight: bold;&quot;&gt;function&lt;/span&gt; loadingBlockerDisable&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#123;&lt;/span&gt;&amp;#160; &amp;#160; &amp;#160;&amp;#160; &amp;#160;&amp;#160; &amp;#160;&amp;#160; &amp;#160;&amp;#160; &amp;#160;&amp;#160; &amp;#160;&lt;br /&gt;&amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; $&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #3366CC;&quot;&gt;&#039;overlyingdiv&#039;&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#41;&lt;/span&gt;.&lt;span style=&quot;color: #006600;&quot;&gt;style&lt;/span&gt;.&lt;span style=&quot;color: #006600;&quot;&gt;visibility&lt;/span&gt;=&lt;span style=&quot;color: #3366CC;&quot;&gt;&#039;hidden&#039;&lt;/span&gt;;&amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &lt;br /&gt;&amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &amp;#160; &lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#125;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&amp;#160;&lt;/div&gt; 
    </content:encoded>

    <pubDate>Tue, 02 Sep 2008 14:22:00 +0200</pubDate>
    <guid isPermaLink="false">http://webconsults.eu/archives/20-guid.html</guid>
    
</item>
<item>
    <title>Messages from Ajax Requests</title>
    <link>http://webconsults.eu/archives/12-Messages-from-Ajax-Requests.html</link>
            <category>JavaScript</category>
            <category>PHP</category>
    
    <comments>http://webconsults.eu/archives/12-Messages-from-Ajax-Requests.html#comments</comments>
    <wfw:comment>http://webconsults.eu/wfwcomment.php?cid=12</wfw:comment>

    <slash:comments>1</slash:comments>
    <wfw:commentRss>http://webconsults.eu/rss.php?version=2.0&amp;type=comments&amp;cid=12</wfw:commentRss>
    

    <author>nospam@example.com (John Behrens)</author>
    <content:encoded>
    Giving back errors from AJAX requests is not that easy all the time.
One possibility is to give back an Error Message by the AJAX Result, 
but this is not that comfortable at any time you have to put an error handling inside your AJAX call which is returning the message to the user.

Another solution are session based error messages for that you have to implement an Ajax error handling class.

For this messages you create a div layer inside your HTML.
&lt;blockquote&gt;
&amp;lt;div id=&quot;messagefield&quot; style=&quot;visibility: hidden;&quot;&amp;gt;
&amp;lt;a href=&quot;#&quot; onclick=&quot;CloseMessageField()&quot;&gt;close&amp;lt;/a&gt;
&amp;lt;div id=&quot;messagefieldtext&quot;&gt;&lt;?PHP echo $onStartGivenErrorText; ?&gt;&amp;lt;/div&amp;gt;
&amp;lt;/div&gt;&#039;;
&amp;lt;?PHP	if($strMessageText){
		echo &quot;&amp;lt;script type=&#039;text/javascript&#039;&amp;gt;
					ShowMessageField()
					&amp;lt;/script&amp;gt;&quot;;
	}
?&amp;gt;
&lt;/blockquote&gt;


This example is using Prototype.
&lt;blockquote&gt;
&amp;lt;script language=&#039;JavaScript&#039;&gt;
			 function CloseMessageField() {
 			 	document.getElementById(&#039;messagefield&#039;).style.visibility = &#039;hidden&#039;;
			 }
			 
			function ShowMessageField() {
 				document.getElementById(&#039;messagefield&#039;).style.visibility = &#039;visible&#039;;
			}
	  	    
			function RefreshMessageField(){
					ajaxRequest=new Ajax.Request(&#039;/your/messege/ajax/url&#039;, 
                			{ method:&#039;get&#039;,                			
                			  onSuccess: function(transport) {
                				  								
    									if(transport.responseText.length &gt; 1){
    										document.getElementById(&#039;messagefieldtext&#039;).innerHTML=document.getElementById(&#039;messagefieldtext&#039;).innerHTML+transport.responseText;
    										ShowMessageField();
										}							
    							}
    						}		
	 						);
	 		}
	 		&amp;lt;/script&amp;gt;
&lt;/blockquote&gt;

Now you create an the AJAX Server by just returning simple HTML code instead XML you save some time
&lt;blockquote&gt;
if(is_array($_SESSION[&#039;errors&#039;] &amp;&amp;amp; count($_SESSION[&#039;errors&#039;]) &gt; 0){
        //returning the errors
         foreach($_SESSION[&#039;errors&#039;] as $strError){
               echo $strError;
         }
         //reset the error string
         $_SESSION[&#039;errors&#039;]=array();
}

&lt;/blockquote&gt;

Now you can give out Errors to a message window just by adding them to a Session like
&lt;blockquote&gt;$_SESSION[&#039;errors&#039;][]=&quot;There has been an error by saving your entry&quot;&lt;/blockquote&gt;

or you can even use it to catch PHP Errors by using the &lt;a href=&quot;http://www.php.net/set_error_handler&quot; title=&quot;set_error_handler&quot;&gt;set_error_handler&lt;/a&gt; function to see the PHP Errors which were thrown during the AJAX request execution.

Any time you have a failed AJAX request you just call the RefreshMessageField() function instead from the returned AJAX response messages. Within your AJAX request you just have to differ between successful answer or showing the error message window.

This example is a bit simplified i wrote myself an own Error handling class which supports multiple reporting modes which differ between a Development mode and Production mode but this should give you an overview how the process works.


 
    </content:encoded>

    <pubDate>Fri, 04 Jul 2008 18:30:00 +0200</pubDate>
    <guid isPermaLink="false">http://webconsults.eu/archives/12-guid.html</guid>
    
</item>
<item>
    <title>JavaScript Sandbox Proxy in PHP</title>
    <link>http://webconsults.eu/archives/8-JavaScript-Sandbox-Proxy-in-PHP.html</link>
            <category>JavaScript</category>
            <category>PHP</category>
    
    <comments>http://webconsults.eu/archives/8-JavaScript-Sandbox-Proxy-in-PHP.html#comments</comments>
    <wfw:comment>http://webconsults.eu/wfwcomment.php?cid=8</wfw:comment>

    <slash:comments>1</slash:comments>
    <wfw:commentRss>http://webconsults.eu/rss.php?version=2.0&amp;type=comments&amp;cid=8</wfw:commentRss>
    

    <author>nospam@example.com (John Behrens)</author>
    <content:encoded>
    Well for your website you´ll often have to include external JavaScript like tags of ad partners, external adserver etc.
These foreign JavaScript is always a security risk, if a optional enemy is able to change the external JS he might take effect of CrossSite Scripting on your site. So how to protect against XSS from partners you need to include but which are possibly evil.

Well there might be the solution of a PHP based JavaScript interpreter wich could handle external JS in a server based sandbox,
&lt;a href=&quot;http://j4p5.sourceforge.net/&quot;&gt;J4P5&lt;/a&gt; might be a solution to it it makes you able to run JavaScript from your PHP Server so it´s a kind of interpreter to it. Based on your server you need to evaluate the JS generated code if it is not generating possibly eval JavaScript. It might cause some disadvatages like if ad tags try to determine your browser, ip, and  maybe some JS scripts are not working of cause will not have a good effect on performance but might prevent some XSS security issues, specially if you include JS from an untrustable third party.
I ll try it out in the next time.
 
    </content:encoded>

    <pubDate>Tue, 17 Jun 2008 11:19:46 +0200</pubDate>
    <guid isPermaLink="false">http://webconsults.eu/archives/8-guid.html</guid>
    
</item>

</channel>
</rss>
