在做ipad兼容,最终还是有很多的问题,所以直接就来两个链接,当是pc访问的时候,就跳转到PC的专用链接,当ipad访问的时候,就跳转到ipad的专用链接,下面是在苹果的官方拿下来的判断ipad的跳转链接代码,大家可以根据需要进行扩展。

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
 
<span style="color: #003366;font-weight: bold">function</span> browser_check<span style="color: #009900">(</span><span style="color: #009900">)</span> <span style="color: #009900">{</span>
 <span style="color: #003366;font-weight: bold">var</span> originalWindowLocation <span style="color: #339933">=</span> window.<span style="color: #660066">location</span> <span style="color: #339933">+</span> <span style="color: #3366CC">""</span><span style="color: #339933">;</span>
 <span style="color: #003366;font-weight: bold">var</span> newWindowLocation<span style="color: #339933">;</span>
 <span style="color: #003366;font-weight: bold">var</span> server <span style="color: #339933">=</span> <span style="color: #3366CC">'http://'</span> <span style="color: #339933">+</span> window.<span style="color: #660066">location</span>.<span style="color: #660066">hostname</span> <span style="color: #339933">+</span> <span style="color: #3366CC">'/ipad'</span><span style="color: #339933">;</span>
 <span style="color: #003366;font-weight: bold">var</span> regexiPad <span style="color: #339933">=</span> <span style="color: #003366;font-weight: bold">new</span> RegExp<span style="color: #009900">(</span><span style="color: #009966;font-style: italic">/iPad/</span><span style="color: #009900">)</span><span style="color: #339933">;</span>
  <span style="color: #000066;font-weight: bold">if</span><span style="color: #009900">(</span> regexiPad.<span style="color: #660066">exec</span><span style="color: #009900">(</span>navigator.<span style="color: #660066">userAgent</span><span style="color: #009900">)</span> <span style="color: #009900">)</span> <span style="color: #009900">{</span>
  newWindowLocation <span style="color: #339933">=</span> server <span style="color: #339933">+</span> <span style="color: #3366CC">'/4/interface/'</span><span style="color: #339933">;</span>
 <span style="color: #009900">}</span> <span style="color: #000066;font-weight: bold">else</span> <span style="color: #009900">{</span>
  newWindowLocation <span style="color: #339933">=</span> <span style="color: #3366CC">'http://support.apple.com/manuals/ipad/'</span><span style="color: #339933">;</span>
 <span style="color: #009900">}</span>
 <span style="color: #000066;font-weight: bold">if</span><span style="color: #009900">(</span> <span style="color: #339933">-</span><span style="color: #CC0000">1</span> <span style="color: #339933">==</span> originalWindowLocation.<span style="color: #660066">indexOf</span><span style="color: #009900">(</span>newWindowLocation<span style="color: #009900">)</span> <span style="color: #009900">)</span> <span style="color: #009900">{</span>
  window.<span style="color: #660066">location</span> <span style="color: #339933">=</span> newWindowLocation <span style="color: #339933">+</span> window.<span style="color: #660066">location</span>.<span style="color: #660066">hash</span><span style="color: #339933">;</span>
 <span style="color: #009900">}</span>
<span style="color: #009900">}</span>
browser_check<span style="color: #009900">(</span><span style="color: #009900">)</span><span style="color: #339933">;</span>