Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Script Determination

Status
Not open for further replies.

tyrannus

MIS
Apr 6, 2006
115
US
Hey all, I have an issue here.
I have a PHP page that makes use of javascript. I have a PHP script set up so that if the browser is IE it runs a certain javascript and if it is Firefox it is running a different script.

What I need to do is determine if the IE of Firefox Script is running.

The issue I am having is that everything works properly in IE, but not in Firefox and I want to be able to determine if the proper script is being run when in firefox.
 
Why do you use different scripts for different browsers? What if the browser is Opera or Safari? I'd suggest writing your Javascript to work in ALL major browsers.

Lee
 
My clients use either IE or Firefox only. One of the scripts I have are supposed to work with either browser but for somereason it doesn't. I just need to know how to test to see which script is being implememted and that is all.
 
It sounds like your question then is about a PHP script, and this is the Javascript forum. I suggested fixing the Javascript since you addressed the problem in this forum.

If you have a question about PHP, that is

forum434

Lee
 
I want to execute a command in the javascript that tells me which one is being used. I have two javascripts. There has to be a way for me to display the results of a variable or something. Or even to tell me which browser is being detected .
 
tyrannus, just put an alert in each script to show what it is.

In script one put in alert('This is script 1');
And in the other, alert('This is script 2');


At my age I still learn something new every day, but I forget two others.
 
My clients use either IE or Firefox only

If that's 100% the truth and firefox and IE are the only 2 browsers you have to worry about, then you can test for IE this way:

Code:
<script type="text/javascript">

if (document.all) {
   alert("I am IE");
}
else {
   alert("I am Firefox");
}

</script>

Lee has the correct idea though, you should write your code to work in all browsers. The above code is really just a sloppy band-aid that has a lot of potential to blow up in the future if any non-IE-or-Firefox users come to your site.

-kaht

Looking for a puppy?

silky-icon-left.gif
[small]Silky Terriers are small, relatively odorless dogs that shed no fur and make great indoor pets.[/small]
silky-icon-right.gif
 
I tried using code that was supposed to work in both browsers, but it wouldn't. The way to manipulate in IE is different than Firefox. However, it is working.. Thanks for all your help.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top