We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
javacript中有一个var av = navigator.appVersion.toLowerCase() || ''; 这里可以判断对应的平台
javacript
var av = navigator.appVersion.toLowerCase() || '';
每个id对应的元素,用下面的方法:
var id = document.getElementById('id'); var href = id.href; var text = id.innerHTML;
如果还有其它元素,也一样
<html> <body> <div id="an"> <a id="desktopClient" target="_blank" hidefocus="true" href="http://githbu.com" title="test">desktop</a> </div> <script > (function (){ var av = navigator.appVersion.toLowerCase() || ''; var is = {}; var dictClientEle = document.getElementById('desktopClient'); var href = dictClientEle.href; var text = dictClientEle.innerHTML; is.mac = /mac/i.test(av); is.win = /win/i.test(av); is.ipad = /ipad/i.test(av); is.linux = /linux/i.test(av); is.iphone = /iphone/i.test(av); is.android = /android/i.test(av); if (is.win) { href = "http://163.com"; text = "windows" } else if (is.mac) { if (is.iphone) { href = "http://163.com"; text = "iphone" } else if (is.ipad) { href = "http://163.com"; text = "ipad" } else { href = "http://163.com"; text = "Mac" } } else if (is.linux) { href = "http://163.com"; text = "Linux" } else if (is.android) { href = "http://163.com"; text = "Android" } dictClientEle.href = href; dictClientEle.innerHTML = text; })(); </script> </body> </html>
The text was updated successfully, but these errors were encountered:
No branches or pull requests
判断平台类型
调用的接口
javacript
中有一个var av = navigator.appVersion.toLowerCase() || '';
这里可以判断对应的平台修改对应的元素
每个id对应的元素,用下面的方法:
如果还有其它元素,也一样
示例代码
总结
The text was updated successfully, but these errors were encountered: