0

Is anyone aware of some code that I can use to exclude certain things from showing in a mobile browser.

I specifically want to exclude certain images and flash files from showing on a website - but only when viewed on a mobile browser.

Something like this but on;t know what 'code' would be.

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

If anyone is able to help I would be grateful.

1 Answer 1

1

It seems like you can look up the META tag with something like this

JavaScript:

var agent=navigator.userAgent.toLowerCase(); var is_iphone = ((agent.indexOf('iphone')!=-1); if (is_iphone) { conditional code goes here } 

Use that to set a variable and then use something like this to check your variable and show/hide some content:

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> 

CSS:

.more { display: none; border-top: 1px solid #666; border-bottom: 1px solid #666; } a.showLink, a.hideLink { text-decoration: none; color: #36f; padding-left: 8px; background: transparent url('down.gif') no-repeat left; } a.hideLink { background: transparent url('up.gif') no-repeat left; } a.showLink:hover, a.hideLink:hover { border-bottom: 1px dotted #36f; } 

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'; } } } 

I will admit that I don't personally follow everything going on here but I think somehow these examples and the two different links can give you the outcome you are after.

Sign up to request clarification or add additional context in comments.

1 Comment

Thanks for this - I have the first part detecting the mobile browser - I will try it out and let you know.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.