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)
-   -   who knows javascript? (https://gfy.com/showthread.php?t=688497)

Pete-KT 12-20-2006 06:41 AM

who knows javascript?
 
Im trying to figure out a way to tell it that if its using IE to use one script but if its useing any other browser to use a different script, I tried usuing regular if else statements but doesnt seem like java likes those

MoviesBucks 12-20-2006 06:54 AM

if(navigator.AppName== 'Netscape') - it's netscape, seamonkey,firefox or whatever, otherwise it's 99% IE

Pete-KT 12-20-2006 06:56 AM

thats of no help to call the JS in html file

Calvinguy 12-20-2006 07:16 AM

What you are describing sounds like bad programing. You should test if a given function is supported by the browser instead of testing what browser is used.

Pete-KT 12-20-2006 07:18 AM

what i wanna do calvin is in the html tell it if its IE use this .js else use the other .js

psili 12-20-2006 07:28 AM

Use a server side script to write the .js include:

if($_SERVER["HTTP_USER_AGENT"] == "so and so")
echo "this.js";
else
echo "that.js";

Or, have your .js file alias to a server side script that does the same thing internally.

Otherwise, I tend to agree with Calvilnguy, that's it'd be better to just write cross-platform JS scripts.

Pete-KT 12-20-2006 08:05 AM

Thanks psili

DaddyHalbucks 12-20-2006 08:07 AM

Is javascript really necessary?

polle54 12-20-2006 08:14 AM

Quote:

Originally Posted by psili (Post 11558018)
Use a server side script to write the .js include:

if($_SERVER["HTTP_USER_AGENT"] == "so and so")
echo "this.js";
else
echo "that.js";

Or, have your .js file alias to a server side script that does the same thing internally.

Otherwise, I tend to agree with Calvilnguy, that's it'd be better to just write cross-platform JS scripts.

are you sure you mean echo????

that's for writing shit in php

psili 12-20-2006 08:17 AM

Quote:

Originally Posted by polle54 (Post 11558145)
are you sure you mean echo????

that's for writing shit in php

Just meant "echo" the include line to the browser... guess it was more pseudo code I threw in there, than anything else.

SmokeyTheBear 12-20-2006 08:46 AM

why not just put the 2 javascript together in one file in sep functions..

this would go in body tag or head tag

Code:

<script src=detect.js></script>
<script>
var browser_type=navigator.appName
var browser_version=parseInt(navigator.appVersion)

//if IE 4+
if (browser_type=="Microsoft Internet Explorer"&&browser_version>=4){
document.write("- press any keyboard key to skip to the next picture -<br>");
ie();
}
else
{

notie();
}
</script>

This would go inside detect.js
Code:


function ie() {

alert('Your using internet explorer');

}
function notie() {

alert('Your not using internet explorer');

}


RazorSharpe 12-20-2006 01:06 PM

hi Pete,

Try this:

http://www.cdnetworx.com/detect.zip

basically, you put the code that is in example.html into the page you want the detection on. Put your firefox javascript into fire.js and your ie specific js into ie.js

should work ... if you have questions, my icq is 125-48-32-18

cheers ...

Pete-KT 12-20-2006 02:19 PM

Thanks Razor and Smokey

RazorSharpe 12-20-2006 05:33 PM

Quote:

Originally Posted by Pete-KT (Post 11559978)
Thanks Razor and Smokey

no worries mate, glad i could help

...


All times are GMT -7. The time now is 11:49 PM.

Powered by vBulletin® Version 3.8.8
Copyright ©2000 - 2025, vBulletin Solutions, Inc.
©2000-, AI Media Network Inc123