實現代碼以下:javascript
1、Html代碼html
<a href="javascript:;" class="xq-sms">發送短信</a>
2、jQuery代碼java
$(document).ready(function(){ var u = navigator.userAgent; var isAndroid = u.indexOf('Android') > -1 || u.indexOf('Linux') > -1; var isIos = !!u.match(/\(i[^;]+;( U;)? CPU.+Mac OS X/); var current_url = window.location.href; if(isAndroid == true){ $(".xq-sms").attr("href","sms:?body="+current_url); } else if(isIos == true){ $(".xq-sms").attr("href","sms:&body="+current_url); } });