Jump to content

ajax system with other protocols


es131245

Recommended Posts

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

post-25874-0-56843800-1332098926_thumb.png

Link to comment
Share on other sites

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

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...