Solved

IE and Netscrape....

Posted on 2000-03-21
6
205 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
  • 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
Windows Server 2016: All you need to know

Learn about Hyper-V features that increase functionality and usability of Microsoft Windows Server 2016. Also, throughout this eBook, you’ll find some basic PowerShell examples that will help you leverage the scripts in your environments!

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

What is SQL Server and how does it work?

The purpose of this paper is to provide you background on SQL Server. It’s your self-study guide for learning fundamentals. It includes both the history of SQL and its technical basics. Concepts and definitions will form the solid foundation of your future DBA expertise.

Question has a verified solution.

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

Suggested Solutions

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.
When setting up new project requests for our site, one of the most powerful tools our team has available to use is Axure (http://www.axure.com/). It’s a tool for creating software and web prototypes that can function and interact as if it were the a…
The purpose of this video is to demonstrate how to update a WordPress Site’s version. WordPress releases new versions of its software frequently and it is important to update frequently in order to keep your site secure, and to get new WordPress…
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…

770 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