Click here to Skip to main content
15,881,852 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi,
I have to redirect to my mobile site. I have created two site's Desktop site and mobile site. If we view in mobile the Side should redirect to mobile site like m.site.com. I given the code
XML
<script type="text/javascript">
$(document).ready(function(){
  if($(window).width() < 480){
           window.location = "http://mobile.yoursite.com"
  }
});
</script>


But when i given this on ready and body load function also, but in these two format the desktop site is first loading and then only it is redirected to mobile site. I try'd <link rel="alternate" media="handheld" href="http://m.yoursite.com">. But this not worked. Is there any other way please help me.
Posted

add
IsScriptEnabled="True" in u r .xaml
 
Share this answer
 
Comments
Unareshraju 8-Jun-12 8:42am    
http://blogs.msdn.com/b/mikeormond/archive/2010/08/26/calling-javascript-functions-in-windows-phone-7.aspx
You should redirect on the server, not on the client

So, in you server side code, perform browser detection by using USER_AGENT - have a look here[^] here which has examples in every language.

If you know the request is coming from a mobile based browser, then redirect to the appropriate sub-domain.
 
Share this answer
 
Comments
ssyuvaraja 8-Jun-12 8:48am    
Where should i past this code. Can you please explain.
Dylan Morley 8-Jun-12 9:32am    
You are coding in PHP yes?
Dylan Morley 8-Jun-12 9:34am    
Have a look at this article

http://www.9lessons.info/2010/09/redirect-mobile-devices-with-php.html
ssyuvaraja 9-Jun-12 0:24am    
Thank you so much. It worked. Credits to you.
please follow the link Link

when you determine the request is from mobile than redirect the page using header function
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900