SitePoint Sponsor

User Tag List

Results 1 to 6 of 6
  1. #1
    SitePoint Enthusiast KieranG's Avatar
    Join Date
    Feb 2008
    Location
    England [NW]
    Posts
    59
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Showing a message to IE users only?

    I would like to display a small message to Internet Explorer users (just a link to firefox with a message) but have no idea how I would do this nor what language is best to do it in. I'm presuming Javascript, but not sure?

    I know that in CSS you can do...

    <!--[if IE 5.5000]>
    <link rel="stylesheet" type="text/css" href="iespecific.css" />
    <![endif]-->

    But that is only for linking stylesheets, right? I wouldn't be able to put a message inside there?

    Thanks a lot,
    Kieran.

  2. #2
    SitePoint Wizard bronze trophy bigalreturns's Avatar
    Join Date
    Mar 2006
    Posts
    1,295
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Well you could use that method by having a div that is normally display:none, but is set to display:block by your IE spreadsheet. The problem is that users with CSS turned off will see the message whether or not they are using IE.
    Your other option is some method of getting the browser string from the user agent, either with javascript, or a server-side language. Server side has the advantage of working even if javascript is turned off. Both have the disadvantage that user agents can easily be changed.
    "The proper function of man is to live - not to exist."
    Get a Free TomTom


  3. #3
    Function Curry'er JimmyP's Avatar
    Join Date
    Aug 2007
    Location
    Brighton, UK
    Posts
    2,006
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    That conditional comment can be used within the body - i.e. just put it into the <body> with the text in there like this:

    Code:
    <!--[if IE]>
    <a href="#">Get firefox NOW!</a>
    <![endif]-->
    James Padolsey
    末末末末末末末末末末末末末末末末末末末
    Awesome JavaScript Zoomer (demo here)
    'Ajaxy' - Ajax integration solution (demo here)

  4. #4
    SitePoint Enthusiast KieranG's Avatar
    Join Date
    Feb 2008
    Location
    England [NW]
    Posts
    59
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Thanks a lot both of you - I will test out the code now Jimmy!

  5. #5
    SitePoint Author silver trophybronze trophy
    wwb_99's Avatar
    Join Date
    May 2003
    Location
    Washington, DC
    Posts
    10,653
    Mentioned
    4 Post(s)
    Tagged
    0 Thread(s)
    That will work. Though the whole "lets force everyone to use firefox" thing died a while back.

  6. #6
    SitePoint Enthusiast KieranG's Avatar
    Join Date
    Feb 2008
    Location
    England [NW]
    Posts
    59
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I only wanted to use it for one of my watch TV online sites. Currently I'm showing the message to everyone (it's another revenue stream as far as i'm concerned), but now it's only displaying to people with IE. Which is better.


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •