2013-05-17 7 views
2

모바일 페이지가 아니면 성공적으로 수행 할 수있는 쿼리 문자열을 사용하려고합니다. 내가하고있는 일은 모바일인지 리디렉션인지 확인하는 것입니다. 리디렉션 URL에 쿼리 문자열을 첨부 할 수 있습니까? 내가 window.location.search으로이 단순화 URL 리디렉션에 쿼리 문자열 추가

var mobile = (/iphone|ipad|ipod|android|blackberry|mini|windows\sce|palm/i.test(navigator.userAgent.toLowerCase())); 
if (mobile) { 
    window.location = "http://www.xxxxxxx.com/mobile" + window.location.search + window.location.hash; 
} 

나는 이것이 당신이 원하는 것 같아요

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> 
<script type="text/javascript">// <![CDATA[ 
    var mobile = (/iphone|ipad|ipod|android|blackberry|mini|windows\sce|palm/i.test(navigator.userAgent.toLowerCase())); 
    if (mobile) { 
     document.location = "http://www.xxxxxxx.com/mobile"; 
    } 
// ]]></script> 
<html xmlns="http://www.w3.org/1999/xhtml"> 
<head> 
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> 

<title>xxxxxxxxx</title> 

<script type="text/javascript"> 
    window.onload = function(){ 
     var total = 0; 
     for(var x = 0; x < parameters.length; x++){ 
      document.getElementById("customerID").value = parameters[x].value; 
     } 
     document.forms[0].onsubmit = validate; 
    } 
</script> 
+2

사이트를 언급하지 않은 모바일 장치가있는 경우 어떻게합니까? 나는 당신이 문제를 잘못 생각하고 있다고 생각합니다. – Sunyatasattva

+0

어때요 :'+ window.location.search'? – McGarnagle

+0

URL에 검색어 문자열을 추가하기 만하면 문제가 발생합니까? – meda

답변