GoFuckYourself.com - Adult Webmaster Forum

GoFuckYourself.com - Adult Webmaster Forum (https://gfy.com/index.php)
-   Fucking Around & Business Discussion (https://gfy.com/forumdisplay.php?f=26)
-   -   Can someone help me with a Javascript problem? (https://gfy.com/showthread.php?t=1171370)

2MuchMark 07-31-2015 05:11 PM

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!

clickity click 07-31-2015 05:18 PM

Fuck Javascript.

freecartoonporn 07-31-2015 07:12 PM

you want to detect users browser or just change
this
<!-- one two three four -->

to

<!-- two three four -->

?

marlboroack 07-31-2015 07:13 PM

and fuck you

2MuchMark 08-01-2015 08:18 AM

Quote:

Originally Posted by freecartoonporn (Post 20538837)
you want to detect users browser or just change
this
<!-- one two three four -->

to

<!-- two three four -->

?


Hiya,

I want to do this : If Browser = IE then

<!-- two three four -->

Else

<!-- one two three four -->

Paul&John 08-01-2015 08:37 AM

Here is one type of code: javascript - jQuery: check if user is using IE - Stack Overflow

Code:

var ua = window.navigator.userAgent;
var msie = ua.indexOf("MSIE ");

if (msie > 0 || !!navigator.userAgent.match(/Trident.*rv\:11\./))
            alert("Its IE");
        else               
            alert("Its NOT IE");


Video-Post 08-01-2015 07:39 PM

Well, here you go - put this between the HEAD and BODY tags:

Code:

<script>
function myFunction() {
var ua = window.navigator.userAgent;
var msie = ua.indexOf("MSIE ");
if (msie > 0 || !!navigator.userAgent.match(/Trident.*rv\:11\./))
document.getElementById("brchk").innerHTML = "<!-- two three four -->";
else               
document.getElementById("brchk").innerHTML = "<!-- one two three four -->";
}
</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>

freecartoonporn 08-02-2015 01:06 AM

what ^^ said will do it.

ravo 08-02-2015 05:21 AM

Quote:

Originally Posted by ********** (Post 20538731)
... my programmers are off partying and getting laid, ...

LOL, rarely hear that about programmers....

WorstDrug 08-02-2015 05:38 AM

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

k0nr4d 08-02-2015 06:40 AM

Maybe this will help

https://msdn.microsoft.com/en-us/lib...=vs.85%29.aspx

Barry-xlovecam 08-02-2015 08:59 AM

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 ...

Video-Post 08-02-2015 03:44 PM

Quote:

Originally Posted by Video-Post (Post 20539476)
Well, here you go - put this between the HEAD and BODY tags:

Code:

<script>
function myFunction() {
var ua = window.navigator.userAgent;
var msie = ua.indexOf("MSIE ");
if (msie > 0 || !!navigator.userAgent.match(/Trident.*rv\:11\./))
document.getElementById("brchk").innerHTML = "<!-- two three four -->";
else               
document.getElementById("brchk").innerHTML = "<!-- one two three four -->";
}
</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>

Sorry, small change - put the first code between the head tags instead of between the HEAD and BODY tags. It should work anyway but better stick to the norm.


Video-Post 08-02-2015 03:51 PM

Oh and I forgot the slash in the span tag. You can simply use:

Code:

<span id="brchk"></span>
...as anything in between the span tags will be changed according to the browser used when the page has loaded. You can also let it execute in real-time as the page renders in the browser.


Video-Post 08-02-2015 04:08 PM

If you want do it in real time, simply paste the code below somewhere inside the HTML tags:

Code:

<span id="brchk"><span>
<script>
var ua = window.navigator.userAgent;
var msie = ua.indexOf("MSIE ");
if (msie > 0 || !!navigator.userAgent.match(/Trident.*rv\:11\./))
document.getElementById("brchk").innerHTML = "<!-- two three four -->";
else               
document.getElementById("brchk").innerHTML = "<!-- one two three four -->";
</script>

Since it's just a quick check, this is probably the easiest and most sensible approach.


Video-Post 08-02-2015 04:10 PM

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