![]() |
Can someone help me with a Javascript problem?
So it's Friday night and my programmers are off partying and getting laid, and I'm staying in and trying to better my smarts with a little website work, and I'm stuck.
I have a line in my page that looks just like this, complete the comment tags. <!-- one two three four --> The above appears in the body of the page. What I want to do is detect if the user on the web page is using Internet Explorer, and if so, to change the code above so that it looks like this: <!-- two three four --> with the "one" removed. Any help is appreciated! |
Fuck Javascript.
|
you want to detect users browser or just change
this <!-- one two three four --> to <!-- two three four --> ? |
and fuck you
|
Quote:
Hiya, I want to do this : If Browser = IE then <!-- two three four --> Else <!-- one two three four --> |
Here is one type of code: javascript - jQuery: check if user is using IE - Stack Overflow
Code:
var ua = window.navigator.userAgent; |
Well, here you go - put this between the HEAD and BODY tags:
Code:
<script> Then insert this in the body tag to trigger the function above once: Code:
<body onload="myFunction()"> Finally, put this between the HTML tags in your document: Code:
<span id="brchk"><!-- lets check --><span> |
what ^^ said will do it.
|
Quote:
|
You're better off handling this logic server-side, saving client-side resources (and making your website a tiny bit faster). I'm guessing that you use PHP since you're asking for technical help on, well, not the most technical forum on the web? :-p
|
|
We capture the User-Agent: headers then output the correct URI for that browser -- I refer to it as the Internet Brick (IE). ** CSS notation is just if statements in the page source ** These headers are sent with the first server request by default. However, that sort of JavaScript would catch when forged headers are sent by a scraping browser :2 cents: that could be useful to verify ...
|
Quote:
|
Oh and I forgot the slash in the span tag. You can simply use:
Code:
<span id="brchk"></span> |
If you want do it in real time, simply paste the code below somewhere inside the HTML tags:
Code:
<span id="brchk"><span> |
Inside the BODY tags to be more precise.
|
All times are GMT -7. The time now is 07:55 AM. |
Powered by vBulletin® Version 3.8.8
Copyright ©2000 - 2025, vBulletin Solutions, Inc.
©2000-, AI Media Network Inc123