Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How to Hide Javascript from IE5/Mac

Status
Not open for further replies.

smileycat

Technical User
Mar 23, 2006
2
US
I am using a JavaScript [] that uses onclick events which are not supported by IE5/Mac.

I'm not a JavaScript programmer so I can't rewrite the JavaScript - so is there a way that I can simply hide the script from this browser?

Thanks for any responses, and for keeping them simple!

--Christian Watson
 
Well one solution would be to do a browser check, and do something else in other browsers.

Checkout
This is one way you could do it:

you can change the onClick to

onClick="textbrowser();"

and insert this at the top of the page
Code:
<script type="text/javascript" src="browser_detect.js"></script>
<script language="Javascript type="text/javascript">
function textbrowser()
{
   if(browser.isIE5x != true && browser.isMac != true)
   {
    //Insert original code in the onClick event
   }
}
</script>

Make sure you do download browser_detect.js from the site.

Hope this helps

-Kerry
 
Question From a Noob: Doesnt the <noscript> tag bypass (hide) JavaScript from browsers that dont support it?
 
The noscript tag provides some HTML to the browser if they do not have javascript enabled. That won't be of any use in this instance.

I have to ask... onclick is supported on IE/Mac... so what specifically are you having a problem with?

Cheers,
Jeff

[tt]Jeff's Page @ Code Couch
[/tt]

What is Javascript? FAQ216-6094
 
Thanks for the feedback and the suggestions - I will certainly look into those.

Sorry about the 'onclick' comment - I think I meant 'addEvent' is not supported by IE5/Mac.

Here's the script I was referring to in case anyone's interested:
Sidenote: ah, how I love to support the 0.8% of our site visitors who still choose to use IE5/Mac!
 
Sorry about the 'onclick' comment - I think I meant 'addEvent' is not supported by IE5/Mac.

You "think" you meant? So what you're saying is your original post was misleading, and you still aren't actually sure what you are saying.

ah, how I love to support the 0.8% of our site visitors who still choose to use IE5/Mac!

How I love to help out people who can't actually tell us what their problem is!

[tt]Dan's Page [blue]@[/blue] Code Couch
[/tt]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top