Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

IE and Netscrape....

Posted on 2000-03-21
6
Medium Priority
?
220 Views
Last Modified: 2013-12-24
With the two browsers vieing for the frontline in browserdom, it is a real problem setting up a webpage with facilities that front page 2000 offers and finding that netscape users arent able to view pages correctly. In fact Netscape tends to crash badly in parts of the site i'm developing ... not a good look .... and i dont feel like fielding questions from disgrunteled netscape users.

Is i possible through java scripting, or whatever to provide the following....

If it is netscape then

....

else

.....

endif

This would allow me to write code on a page per page basis rather than having to develop two duplicate websites !!

I know how to test for the browser ... what i dont know is how to use this information in any way other than to
call a different piece of html.

Any thoughts would be appreciated

Thanks,

Brendan Vowles
0
Comment
Question by:Bren
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 4
  • 2
6 Comments
 
LVL 1

Expert Comment

by:damianosky
ID: 2639335
Your is a common problem. Netscape has some bugs of itself (it crashes also without forntpage extension page) and this is worse with extension...

Obviously yes, you can check the browser type. The code is the following:

      if (navigator.appName.indexOf("Microsoft") >= 0)
      {
            document.location.href = "IEpage.asp"
      }
      else
      {
            document.location.href = "NSpage.asp"
      }

You can control also the version of the browser through the appVersion method of the navigator object:

version = parseInt(navigator.appVersion);

With this code you can simply redirect the browser (suggested method!!!). Alternatively, you can get a different output, simply using the same If ... structure to write different HTML code using the write method, e.g.:

document.write('<H2>Text to write</H2><BR>')





0
 

Author Comment

by:Bren
ID: 2639522
Sorry but i really need more information .... could you supply me with some examples so i have an idea how to apply the codeing to the html ??

Thanks
0
 
LVL 1

Expert Comment

by:damianosky
ID: 2639699
You have to put in your page this:


<script language="javascript">
<!--
if (navigator.appName.indexOf("Microsoft") >= 0)
{
  // this code will be written only on Explorer
  document.write('<H2>Text to write specific for Explorer</H2><BR>')
  document.write('<H3>Good Work with explorer</H3><BR>')
}
else
{
  // this code will be written only on Netscape
  document.write('<H2>Text to write specific for Netscape</H2><BR>')
  document.write('<H2>Good Work with  Netscape</H2><BR>')
}
//-->
</script>

Every time you need to differentiate the code for the two browsers, use this schema: in the write() method put the code you need different for the two browsers.

You can do that more and more. Keep in mind, however, that this will be on client side, so all the page you wirte will be dowloaded, not only the specific part.

So, if you have to do muche different the two pages, is better to redirect to different small pages.


0
Understanding Web Applications

Without even knowing it, most of us are using web applications on a daily basis. Gmail and Yahoo email, Twitter, Facebook, and eBay are used by most of us daily—and they are web applications. We often confuse these web applications tools for websites.  So, what is the difference?

 
LVL 1

Expert Comment

by:damianosky
ID: 2639713
<html>
<head>
<link rel="stylesheet" type="text/css" href="../library/style.css">
<meta http-equiv="Content-Type" content="text/html; charset=windows-1252">
<meta http-equiv="Content-Language" content="it">
<meta name="GENERATOR" content="Microsoft FrontPage 4.0">
<meta name="ProgId" content="FrontPage.Editor.Document">
<meta name="Microsoft Border" content="none">

<title>test</title>
</head>

<body topmargin="0" leftmargin="0">

<script language="javascript">
<!--
if (navigator.appName.indexOf("Microsoft") >= 0)
{
  // this code will be written only on Explorer
  document.write('<H2>Hello Explorer User</H2><BR>')
}
else
{
  // this code will be written only on Netscape
  document.write('<H2>Hello Netscape User</H2><BR>')
}
//-->
</script>

<!-- Common part -->
<p>This is a nice day!!!</p>


<script language="javascript">
<!--
if (navigator.appName.indexOf("Microsoft") >= 0)
{
  // this code will be written only on Explorer
  document.write('<p>Hope you like Explorer</p><BR>')
)
  document.write('<H3>Good Work with explorer</H3><BR>')

}
else
{
  // this code will be written only on Netscape
  document.write('<H2>Hope you like Netscape</H2><BR>')
  document.write('<H2>Good Work with  Netscape</H2><BR>')
}
//-->
</script>

</body>
</html>

Try this code: on Explorer you'll get:

Hello Explorer User
This is a nice day!!!
Hope you like Explorer
Good Work with Explorer

On Netscape

Hello Netscape User
This is a nice day!!!
Hope you like Netscape
Good Work with Netscape


Hope this help you.
0
 
LVL 1

Accepted Solution

by:
damianosky earned 400 total points
ID: 2639733
Tha same you can do with javascript function (e.g., to avoid compatibility issues between the 2 browsers):

<html>
<head>
<link rel="stylesheet" type="text/css" href="../library/style.css">
<meta http-equiv="Content-Type" content="text/html; charset=windows-1252">
<meta http-equiv="Content-Language" content="it">
<meta name="GENERATOR" content="Microsoft FrontPage 4.0">
<meta name="ProgId" content="FrontPage.Editor.Document">
<meta name="Microsoft Border" content="none">

<title>test</title>

<script language="Javascript">
<!--
function WriteMyMessage()
{
  if (navigator.appName.indexOf("Microsoft") >= 0)
  {
    // this code will be written only on Explorer
    document.write('<p>Hope you like Explorer</p><BR>')
)
    document.write('<H3>Good Work with explorer</H3><BR>')

  }
  else
  {
    // this code will be written only on Netscape
    document.write('<H2>Hope you like Netscape</H2><BR>')
    document.write('<H2>Good Work with  Netscape</H2><BR>')
  }
}

//-->
</script>

</head>

<body topmargin="0" leftmargin="0">
<script language="Javascript">
<!--
WriteMyMessage();
//-->
</script>
</body>
</html>


The output will be different according to browsers and, if in your function want to use specific implementation of the javascript (wich is a bit different between MSIE e NS), you can do that, without no more problems.

You can add more and more complexity, e.g. with browsers and javascript version (1.0, 1.1, 1.2). The limit is only your fantasy and, of course, page size.


0
 

Author Comment

by:Bren
ID: 2639796
Thank you .... your input has been most helpful
0

Featured Post

The top UI technologies you need to be aware of

An important part of the job as a front-end developer is to stay up to date and in contact with new tools, trends and workflows. That’s why you cannot miss this upcoming webinar to explore the latest trends in UI technologies!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article provides a case study on how our local youth baseball league deployed a new website, including the platform selection, implementation and benefits to the league.
Originally, this post was published on Monitis Blog, you can check it here . It goes without saying that technology has transformed society and the very nature of how we live, work, and communicate in ways that would’ve been incomprehensible 5 ye…
The purpose of this video is to demonstrate how to create a Printer Friendly PDF on a WordPress Page. This will be demonstrated using a Windows 8 PC. Tools Used are Photoshop, Awesome Screenshot” Google Chrome Extension, and SmallPDF.com Log…
The purpose of this video is to demonstrate how to Import and export files in WordPress. This will be demonstrated using a Windows 8 PC. Go to your WordPress login page. This will look like the following: mywebsite.com/wp-login.php : Click on Too…

688 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question