Javascript 排除在移动浏览器中运行的代码

Javascript 排除在移动浏览器中运行的代码,javascript,jquery,android,html,mobile,Javascript,Jquery,Android,Html,Mobile,是否有人知道我可以使用某些代码将某些内容从移动浏览器中排除 我特别想排除某些图像和flash文件在网站上的显示,但仅限于在移动浏览器上查看时 像这样的东西,但是在上面;我不知道“代码”是什么 <code><img src="smiley.gif" alt="Smiley face" width="32" height="32" /></code> 如果有人能帮助我,我将不胜感激。看来你可以查阅 JavaScript: var agent=navigato

是否有人知道我可以使用某些代码将某些内容从移动浏览器中排除

我特别想排除某些图像和flash文件在网站上的显示,但仅限于在移动浏览器上查看时

像这样的东西,但是在上面;我不知道“代码”是什么

<code><img src="smiley.gif" alt="Smiley face" width="32" height="32" /></code>

如果有人能帮助我,我将不胜感激。

看来你可以查阅

JavaScript:

var agent=navigator.userAgent.toLowerCase();
var is_iphone = ((agent.indexOf('iphone')!=-1);
if (is_iphone) { conditional code goes here }
用它来设置一个变量,然后用类似这样的方法来检查变量和

XHTML:

<p>...This is all visible content... 
<a href="#" id="example-show" class="showLink" 
onclick="showHide('example');return false;">See more.</a>
</p>
<div id="example" class="more">
<p>...This content is hidden by default...</p>
<p><a href="#" id="example-hide" class="hideLink" 
onclick="showHide('example');return false;">Hide this content.</a></p>
</div>
JavaScript:

function showHide(shID) {
    if (document.getElementById(shID)) {
        if (document.getElementById(shID+'-show').style.display != 'none') {
            document.getElementById(shID+'-show').style.display = 'none';
            document.getElementById(shID).style.display = 'block';
        }
        else {
            document.getElementById(shID+'-show').style.display = 'inline';
            document.getElementById(shID).style.display = 'none';
        }
    }
}

我承认,我个人并不关注这里发生的所有事情,但我认为这些例子和两个不同的链接可以让你得到你想要的结果。

谢谢这一点-我有检测手机浏览器的第一部分-我会尝试一下,让你知道。
function showHide(shID) {
    if (document.getElementById(shID)) {
        if (document.getElementById(shID+'-show').style.display != 'none') {
            document.getElementById(shID+'-show').style.display = 'none';
            document.getElementById(shID).style.display = 'block';
        }
        else {
            document.getElementById(shID+'-show').style.display = 'inline';
            document.getElementById(shID).style.display = 'none';
        }
    }
}