es131245 Posted March 18, 2012 Share Posted March 18, 2012 I'm using a php+ajax system with few design "modifications" but ive came into a situation where your help is nesesery.Moreover, I've havent been here for some time, so any of your advise and opinions will be very helpfull.Here are sources with ideas =) Php, for undestanding ajax responce. if(isset($_GET['method'])&&$_GET['method']=='ajax'){if(isset($CFG['content']['style'])){print(' <style type="text/css">'."\n".$CFG['content']['style'].' </style>'."\n");} if(isset($CFG['content']['script'])){print(' <script type="text/javascript">'."\n".' /*<![CDATA[*//*---->*/'."\n".$CFG['content']['script'].' /*--*//*]]>*/'."\n".' </script>')."\n";} if(isset($CFG['content']['body'])){print($CFG['content']['body']);}}else{if(isset($mysql_connect)){mysql_close($mysql_connect);} if(isset($CFG['content']['head'])){print($CFG['content']['head']);} if(isset($CFG['content']['style'])){print(' <style type="text/css">'."\n".$CFG['content']['style'].' </style>'."\n");} if(isset($CFG['content']['script'])){print(' <script type="text/javascript">'."\n".' /*<![CDATA[*//*---->*/'."\n".$CFG['content']['script'].' /*--*//*]]>*/'."\n".' </script>')."\n";} if(isset($CFG['content']['body'])){print($CFG['content']['body']);} if(isset($CFG['content']['footer'])){print($CFG['content']['footer']);}} /*<![CDATA[*//*---->*/function page(url){$('#content').fadeTo(500,0); setTimeout(function() {if(window.XMLHttpRequest){xmlhttp=new XMLHttpRequest();} else{xmlhttp=new ActiveXObject('Microsoft.XMLHTTP');} xmlhttp.onreadystatechange=function() {if(xmlhttp.readyState==4&&xmlhttp.status==200) {document.getElementById('content').innerHTML=xmlhttp.responseText; links(); $('#content').fadeTo(500,1);} else if(xmlhttp.status!=200){window.location.assign(url);}} xmlhttp.open('GET',url+'?method=ajax',true); xmlhttp.send();},500);}function links(){for(var i=0;document.getElementsByTagName('a')[i];i++) {document.getElementsByTagName('a')[i].onclick=function() {page(this.href); return false;}}}window.onload=function(){links();}/*--*//*]]>*/ Works perfectly with local sites links and links to other sites but email,skype and other protocols links... <a href="mailto:mail@gmail.ru">EmailUs</a><<a href="skype:1234567890">SkypeMe</a>< FireFox error console gives "component return failure". Details in attached print Link to comment Share on other sites More sharing options...
justsomeguy Posted March 19, 2012 Share Posted March 19, 2012 What exactly do you expect to happen if you use ajax (to send an HTTP request) to a URL that does not use HTTP? What is the browser supposed to do when you ask it to send an HTTP request to a mailto URL? Link to comment Share on other sites More sharing options...
es131245 Posted March 19, 2012 Author Share Posted March 19, 2012 I expect you to turn me on the right direction to find a way for excluding other protocols using "if else" =) Link to comment Share on other sites More sharing options...
justsomeguy Posted March 19, 2012 Share Posted March 19, 2012 In the links function inside the loop that assigns the click handler to each element, validate the href attribute first. Check if it has a colon, if it does then make sure that the part before the colon contains "http". If not, don't assign the click handler to the element. If it doesn't contain a colon then it is a relative link and you can assume HTTP. Link to comment Share on other sites More sharing options...
es131245 Posted March 19, 2012 Author Share Posted March 19, 2012 Thanks =)As i thought, no magic here, but reliable as a clock. Link to comment Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.