473,666 Members | 2,294 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

test for ie or netscape

I have seen some codes that can test for the browser and give values
accordingly. I tried to read the FAQ, but was unable to find a simple
version of this. What I want is

If Netscape-test {
code for netscape users
}

If IE-test {
code for ie users
}

Jul 20 '05 #1
25 3891
On Tue, 3 Feb 2004 14:12:12 -0600, Treetop <tr*****@netfro nt.net> wrote:
I have seen some codes that can test for the browser and give values
accordingly. I tried to read the FAQ, but was unable to find a simple
version of this.


Why do you want to do this? If you are trying to determine what code *can*
be executed, use feature detection, not browser detection. For example, to
see if document.getEle mentById() is supported use

if( document.getEle mentById ) {
}

Mike

--
Michael Winter
M.******@blueyo nder.co.invalid (replace ".invalid" with ".uk" to reply)
Jul 20 '05 #2
I have created a script to send data, text and an image src, to an
iframe. I have code that works for IE, and I have code that works for
Netscape, but I can't find code that works for both. I want the
following

if test-for-netscape {
window.frames['external'].setup(links[aNum]);
}
else {
document.extern al.setup(links[aNum]);
}
"Michael Winter" <M.******@bluey onder.co.invali d> wrote in message
news:op******** ******@news-text.blueyonder .co.uk...
On Tue, 3 Feb 2004 14:12:12 -0600, Treetop <tr*****@netfro nt.net> wrote:
I have seen some codes that can test for the browser and give values accordingly. I tried to read the FAQ, but was unable to find a simple version of this.
Why do you want to do this? If you are trying to determine what code

*can* be executed, use feature detection, not browser detection. For example, to see if document.getEle mentById() is supported use

if( document.getEle mentById ) {
}

Mike

--
Michael Winter
M.******@blueyo nder.co.invalid (replace ".invalid" with ".uk" to

reply)
Jul 20 '05 #3
In article <bv************ @ID-221536.news.uni-berlin.de>,
tr*****@netfron t.net enlightened us with...
I have seen some codes that can test for the browser and give values
accordingly. I tried to read the FAQ, but was unable to find a simple
version of this. What I want is


And if I use Opera? Or Safari? Or Konqueror? Mac users tend to like
Safari. What about Mozilla? Linux users tend to like Mozilla.
What about if I use Netscape 4? It isn't anything close to Netscape 6 in
regards to what it can do.
How about if I use IE3? It doesn't support half the stuff IE5 does.

Don't test for browsers. You'll end up coming back here wondering why
your code doesn't work in Netscape 8 when it comes out or something.
Test for the objects you want to use.
if (document.layer s)
// do something with that for NN4
else if (document.all && ! document.getEle mentById)
// do something with old IE
else if (document.getEl ementById)
// recent browsers like IE5+, NN6+, Mozilla, Opera...
--
--
~kaeli~
Those who jump off a bridge in Paris... are in Seine.
http://www.ipwebdesign.net/wildAtHeart
http://www.ipwebdesign.net/kaelisSpace

Jul 20 '05 #4

"kaeli" <ti******@NOSPA M.comcast.net> wrote in message
news:MP******** *************** *@nntp.lucent.c om...
In article <bv************ @ID-221536.news.uni-berlin.de>,
tr*****@netfron t.net enlightened us with...
I have seen some codes that can test for the browser and give values accordingly. I tried to read the FAQ, but was unable to find a simple version of this. What I want is

And if I use Opera? Or Safari? Or Konqueror? Mac users tend to like
Safari. What about Mozilla? Linux users tend to like Mozilla.
What about if I use Netscape 4? It isn't anything close to Netscape

6 in regards to what it can do.
How about if I use IE3? It doesn't support half the stuff IE5 does.

Don't test for browsers. You'll end up coming back here wondering why your code doesn't work in Netscape 8 when it comes out or something.
Test for the objects you want to use.
if (document.layer s)
// do something with that for NN4
else if (document.all && ! document.getEle mentById)
// do something with old IE
else if (document.getEl ementById)
// recent browsers like IE5+, NN6+, Mozilla, Opera...


I need to have a way to test for IE5+ versus NN6+.
For my code to work for NN6 I need the following:

window.frames['external'].setup(links[aNum]);
For IE6 I need the following:

document.extern al.setup(links[aNum]);

Jul 20 '05 #5
In article <bv************ @ID-221536.news.uni-berlin.de>,
tr*****@netfron t.net enlightened us with...

I need to have a way to test for IE5+ versus NN6+.
I bet you don't.


For my code to work for NN6 I need the following:

window.frames['external'].setup(links[aNum]);
For IE6 I need the following:

document.extern al.setup(links[aNum]);


That makes no sense to me without a context.

Are you trying to call a function resident (defined) in another frame of
a frameset?
If so, the following is mine (well, it's HVMenu's really) and it works
on both IE5+ and NN6+.
It is called from the "main" frame of a 3 frame (top, left, main)
layout. It calls a function defined in the 'left' frame from the 'main'
frame.

if(parent.frame s[0]&&parent.fra mes['leftFrame'].Go)
{
parent.frames['leftFrame'].Go();
}

If that's the kind of thing you're trying, tell me more about your frame
layout and what frame is calling what function and what frame name that
function is in.

--
--
~kaeli~
A backward poet writes... inverse.
http://www.ipwebdesign.net/wildAtHeart
http://www.ipwebdesign.net/kaelisSpace

Jul 20 '05 #6
On Tue, 03 Feb 2004 20:39:38 GMT, Treetop <tr*****@netfro nt.net> wrote:
I have created a script to send data, text and an image src, to an
iframe. I have code that works for IE, and I have code that works for
Netscape, but I can't find code that works for both. I want the
following

if test-for-netscape {
window.frames['external'].setup(links[aNum]);
}
else {
document.extern al.setup(links[aNum]);
}


I don't know if this will work, but give it a shot:

var ifExternal = null;

if( window.frames['external'] ) {
ifExternal = window.frames['external'];
} else if( document.extern al ) {
ifExternal = window.external ;
}

if( ifExternal ) {
ifExternal.setu p( links[ aNum ]);
}

The need for the two different code paths seems to be because IE (and
Opera) don't include IFRAMEs in the frames collection, though they do
support the frames collection in general (or seem to).

Mike

--
Michael Winter
M.******@blueyo nder.co.invalid (replace ".invalid" with ".uk" to reply)
Jul 20 '05 #7
I have read the following message from "Treetop" <tr*****@netfro nt.net>
and have decided to lend my vast knowledge.

The writer said:
I have seen some codes that can test for the browser and give values
accordingly. I tried to read the FAQ, but was unable to find a simple
version of this. What I want is

If Netscape-test {
code for netscape users
}

If IE-test {
code for ie users
}


and my reply is:
Do a Google search on "browser sniffer"

--
Dennis M. Marks
http://www.dcs-chico.com/~denmarks/
Replace domain.invalid with dcsi.net
-----= Posted via Newsfeeds.Com, Uncensored Usenet News =-----
http://www.newsfeeds.com - The #1 Newsgroup Service in the World!
-----== Over 100,000 Newsgroups - 19 Different Servers! =-----
Jul 20 '05 #8
OK he it goes...... Some of my clients are local contractors /
construction companies. They like to have images to show off current
and past projects. Most of the time it involves an image and some
text to explain what picture is. The last update I did was over 70
images. I decided to have a blank page that could be updated with a
link, that would put the source for the image and text for the image
on that page, to save me time creating 70 pages. I was unable to find
a way and had to create 70 pages. Not fun.

Today I finally put enough information together from different sources
to create the following code in two pages. I don't like they way I
trick the system into using the correct code. I also don't have a way
to test other browsers other than IE and Netscape. This code works on
my sytem in both IE 6 and Netscape 7.02.

Netscape uses this code:
window.frames['external'].setup(links[aNum]);}

IE uses this code:
document.extern al.setup(links[aNum]);

index page:

<table border="1" width="600">
<tr valign="top">
<td width="200">

<script language="javas cript" type="text/javascript">

var links=new Array();
links[4]=new Array("pic1.jpg ","pic1 link text","text for pic1");
links[3]=new Array("pic2.jpg ","pic2 link text","text for pic2");
links[2]=new Array("pic3.jpg ","pic3 link text","text for pic3");
links[1]=new Array("pic4.jpg ","pic4 link text","text for pic4");

function showImg(aNum)
{
if (navigator.appN ame.substring(0 , 7) != "Microso"){
window.frames['external'].setup(links[aNum]);}
else {
document.extern al.setup(links[aNum]);
}
};
for (var i=links.length-1;i>=0;i--)
{
document.write( '<a href="#" onclick=showImg ("'+i+'")>' + links[i][1] +
'</a><br>');
}

</script>

</td>
<td align="center" width="500">
<iframe name="external" id="external" style="width:10 0%;height:500px "
src="picture.ht ml"></iframe>
</td></tr></table>


here is the code in the pictrure.html file

<script language="javas cript">
function setup(aLink)
{
document.getEle mentById("pic") .src=aLink[0];
document.getEle mentById("title ").innerHTML=aL ink[2];
}
</script>
</head>
<body>

<center>
<img src="pic1.jpg" id="pic">
<p id="title">Tex t for Pic1</p>
</center>

Jul 20 '05 #9
OK he it goes...... Some of my clients are local contractors /
construction companies. They like to have images to show off current
and past projects. Most of the time it involves an image and some
text to explain what picture is. The last update I did was over 70
images. I decided to have a blank page that could be updated with a
link, that would put the source for the image and text for the image
on that page, to save me time creating 70 pages. I was unable to find
a way and had to create 70 pages. Not fun.

Today I finally put enough information together from different sources
to create the following code in two pages. I don't like they way I
trick the system into using the correct code. I also don't have a way
to test other browsers other than IE and Netscape. This code works on
my sytem in both IE 6 and Netscape 7.02.

Netscape uses this code:
window.frames['external'].setup(links[aNum]);}

IE uses this code:
document.extern al.setup(links[aNum]);

index page:

<table border="1" width="600">
<tr valign="top">
<td width="200">

<script language="javas cript" type="text/javascript">

var links=new Array();
links[4]=new Array("pic1.jpg ","pic1 link text","text for pic1");
links[3]=new Array("pic2.jpg ","pic2 link text","text for pic2");
links[2]=new Array("pic3.jpg ","pic3 link text","text for pic3");
links[1]=new Array("pic4.jpg ","pic4 link text","text for pic4");

function showImg(aNum)
{
if (navigator.appN ame.substring(0 , 7) != "Microso"){
window.frames['external'].setup(links[aNum]);}
else {
document.extern al.setup(links[aNum]);
}
};
for (var i=links.length-1;i>=0;i--)
{
document.write( '<a href="#" onclick=showImg ("'+i+'")>' + links[i][1] +
'</a><br>');
}

</script>

</td>
<td align="center" width="500">
<iframe name="external" id="external" style="width:10 0%;height:500px "
src="picture.ht ml"></iframe>
</td></tr></table>


here is the code in the pictrure.html file

<script language="javas cript">
function setup(aLink)
{
document.getEle mentById("pic") .src=aLink[0];
document.getEle mentById("title ").innerHTML=aL ink[2];
}
</script>
</head>
<body>

<center>
<img src="pic1.jpg" id="pic">
<p id="title">Tex t for Pic1</p>
</center>
Jul 20 '05 #10

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
10038
by: Robert Oschler | last post by:
I'd like to be able to see if a URL was functional before I attempt to put it in an IFrame. Is there a way to do this so I can prevent the user from ending up with a 404 error page in the IFrame? thx -- Robert Oschler "Let the web hear you, add your voice to your web site in minutes!"
3
10477
by: viza | last post by:
Hi! I use the onscroll event to make something like the CSS position:fixed; for MSIE. In MSIE/5.5, before a function is assigned to the event handler, it has the value null. In Opera, it is undefined, because Opera doesn't support this event. I use:
133
6869
by: Alan Silver | last post by:
Hello, Just wondered what range of browsers, versions and OSs people are using to test pages. Also, since I don't have access to a Mac, will I have problems not being able to test on any Mac browsers, or is there some other way of checking? TIA --
5
2767
by: Martijn Saly | last post by:
I'd like to test in my script, if it's going to be possible to enable priviliges. If I use this... netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect") ....it presents a dialog to the user asking if it's ok. Now I don't want to hide that dialog, I'd like to know if it's going to be possible to click the Allow button, before ever making this call. Basically I need
60
4985
by: marss | last post by:
Maybe anyone know good free online JavaScript knowledge test? This not exactly a system for testing online required - it may be simply list of questions with variants of answers (I have to prepare tests for learners and I need something to be taken as basis). I was able to find only this (http://www.w3schools.com/js/ js_quiz.asp), but I need more. Thanks, Mykola
2
5074
by: emily224 | last post by:
Hello, I have been trying to understand this source code, which I retreived from my online course test. I would like to know how to find the answer for the question on the test. Im sure the answer must be embedded somewhere in the source code, and I would like to know if anyone knows where to find the correct answer. I would greatly appreciate it!! Thanks!! <!--put the preloads file here as it must load before the website class...
4
68198
by: emily224 | last post by:
Hello, I have been trying to understand this source code, which I retreived from my online course test. I would like to know how to find the answer for the question on the test. Im sure the answer must be embedded somewhere in the source code, and I would like to know if anyone knows where to find the correct answer. I would greatly appreciate it!! Thanks!!
6
1815
by: Aaron Gray | last post by:
Hi, I know the 'document.getElementById()' issue is really over since every browser since 1998 supports the W3C DOM standard, but I could not resist this offering :- if (!document.getElementById) document.getElementById = function(id) { return document.all; } This should then provide a getElementById function if one does not already
0
8356
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
8781
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
8550
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
7385
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
6192
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5663
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4198
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4366
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
2011
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.