SitePoint Sponsor |
|
User Tag List
Results 1 to 19 of 19
Thread: Show Text for Useragent I.E
-
Dec 18, 2008, 10:48 #1
- Join Date
- May 2006
- Location
- England
- Posts
- 133
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
Show Text for Useragent I.E
Hey,
Due to a bug in I.E that doesn't render code properly, i'm forced to 'cloak' for I.E user agents only.
Any suggestions on best doing this?
-
Dec 18, 2008, 10:55 #2
- Join Date
- Oct 2004
- Location
- Birtley, UK
- Posts
- 2,439
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
Which bug is this?
What do you mean by cloak?
Am I assuming your wanting to adjust the user agent of the client?
-
Dec 18, 2008, 11:06 #3
- Join Date
- May 2006
- Location
- England
- Posts
- 133
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
Basically if the user is using I.E, i want to show content.
-
Dec 18, 2008, 11:37 #4
- Join Date
- Oct 2004
- Location
- Birtley, UK
- Posts
- 2,439
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
Using the http_user_agent header and if required the get_browser call in PHP, you can find out which browser and version.
http://us3.php.net/function.get-browser
-
Dec 18, 2008, 12:00 #5
- Join Date
- May 2006
- Location
- England
- Posts
- 133
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
Cheers ears. :-)
-
Dec 18, 2008, 12:34 #6
- Join Date
- Sep 2005
- Location
- Sydney, NSW, Australia
- Posts
- 16,875
- Mentioned
- 25 Post(s)
- Tagged
- 1 Thread(s)
Of course ANY useragent could be Internet Explorer since in IE that user field can be set to any value that you like (just as it can in Firefox).
Stephen J Chapman
javascriptexample.net, Book Reviews, follow me on Twitter
HTML Help, CSS Help, JavaScript Help, PHP/mySQL Help, blog
<input name="html5" type="text" required pattern="^$">
-
Dec 18, 2008, 12:36 #7
- Join Date
- Jul 2006
- Location
- Ontario, Canada
- Posts
- 424
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
You could also consider doing this at the client-side rather than with PHP through the use of conditional comments.
-
Dec 18, 2008, 13:04 #8
- Join Date
- May 2006
- Location
- England
- Posts
- 133
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
Doing it client side is a bad idea. Very bad.
-
Dec 18, 2008, 13:24 #9
- Join Date
- Jul 2006
- Location
- Ontario, Canada
- Posts
- 424
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
Can you elaborate on that?
-
Dec 18, 2008, 14:09 #10
- Join Date
- Apr 2008
- Location
- North-East, UK.
- Posts
- 6,111
- Mentioned
- 3 Post(s)
- Tagged
- 0 Thread(s)
@AnthonySterling: I'm a PHP developer, a consultant for oopnorth.com and the organiser of @phpne, a PHP User Group covering the North-East of England.
-
Dec 18, 2008, 14:38 #11
- Join Date
- Sep 2005
- Location
- Sydney, NSW, Australia
- Posts
- 16,875
- Mentioned
- 25 Post(s)
- Tagged
- 1 Thread(s)
It can ONLY be done client side with conditional comments. Any other way would be adding to the problem rather than fixing it.
Stephen J Chapman
javascriptexample.net, Book Reviews, follow me on Twitter
HTML Help, CSS Help, JavaScript Help, PHP/mySQL Help, blog
<input name="html5" type="text" required pattern="^$">
-
Dec 18, 2008, 20:02 #12
- Join Date
- May 2006
- Location
- England
- Posts
- 133
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
Okay, basically I have to add some javascript onclick code to links, due to an I.E bug that stops them from working. So, I don't really want to be adding the onclick code for any other browsers apart from I.E, thats where the useragent comes into play. :-)
I doubt anyone who uses the site will ever have enough know-how to change the useragent themselves.
...and it's better from a seo perspective if I do not bog down the code with conditionals.
-
Dec 18, 2008, 20:27 #13
- Join Date
- Jul 2008
- Posts
- 5,757
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
That sounds like a prime reason to do it clientside instead of serverside. Have the javascript attach the onclick handlers to the links.
But...your links won't work unless javascript is enabled in IE? Are you really sure you sure you can't fix the real problem?
-
Dec 18, 2008, 20:45 #14
- Join Date
- May 2006
- Location
- England
- Posts
- 133
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
It is the only solution I've manged to come up with. :-(
http://is.gd/crqY -- Try to click one of the thumbnails, in I.E.
-
Dec 18, 2008, 21:09 #15
- Join Date
- Jul 2008
- Posts
- 5,757
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
Yeah, odd.
Have you tried removing all script and css to see if the problem remains? The html had a few errors you might wanna fix, although they seem minor.
-
Dec 18, 2008, 21:20 #16
- Join Date
- May 2006
- Location
- England
- Posts
- 133
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
It's the CSS that is a problem and I know exactly where it is, but I just haven't been able to find a fix for it. Sad :-(
It's the block element on the a span.
-
Dec 18, 2008, 21:56 #17
- Join Date
- Jul 2008
- Posts
- 5,757
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
I would really seek another way around before I thought about telling IE users they better have javascript enabled if they wanna click my thumbnails. Surely you can find a way around, even if maybe your markup and css isnt as cool.
My css/html knowledge isn't great, but I thought you weren't even supposed to put block level elements inside of inline elements?
-
Dec 18, 2008, 22:00 #18
- Join Date
- May 2006
- Location
- England
- Posts
- 133
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
Bah, guess i'll have to recode that bit then. :-(
-
Dec 19, 2008, 00:48 #19
- Join Date
- Sep 2005
- Location
- Sydney, NSW, Australia
- Posts
- 16,875
- Mentioned
- 25 Post(s)
- Tagged
- 1 Thread(s)
You can always use JScript conditionals within your JScript for anything that you want JavaScript to treat as a comment. Since IE runs JScript and all the other browsers run JavaScript a JScript conditional in the code will be treated as a JavaScript comment by all browsers except IE.
Stephen J Chapman
javascriptexample.net, Book Reviews, follow me on Twitter
HTML Help, CSS Help, JavaScript Help, PHP/mySQL Help, blog
<input name="html5" type="text" required pattern="^$">
Bookmarks