Solved

IE and Netscrape....

Posted on 2000-03-21
6
209 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
Efficient way to get backups off site to Azure

This user guide provides instructions on how to deploy and configure both a StoneFly Scale Out NAS Enterprise Cloud Drive virtual machine and Veeam Cloud Connect in the Microsoft Azure Cloud.

 
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

NFR key for Veeam Backup for Microsoft Office 365

Veeam is happy to provide a free NFR license (for 1 year, up to 10 users). This license allows for the non‑production use of Veeam Backup for Microsoft Office 365 in your home lab without any feature limitations.

Question has a verified solution.

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

Now that Expression Web 4.0 (http://www.microsoft.com/expression/products/Upgrade.aspx) is free if you buy or have the full version of Expression Web 3.0, now is the best time to  migrate from FrontPage to Expression Web (http://www.frontpage-to-exp…
Introduction In this tutorial, I'll explain how to create an animated progress meter in a wireframe prototype developed using Axure RP 7.0 - a leading prototyping tool for designing web sites and software. (For more information about Axure and gett…
The purpose of this video is to demonstrate how to integrate Mailchimp with WordPress, by placing a Mailchimp signup form on a WordPress Page or Post. This will be demonstrated using a Windows 8 PC. Mailchimp will be used. Log into your Mailchi…
The purpose of this video is to demonstrate how to prevent comment spam on a WordPress Website. This will be demonstrated using a Windows 8 PC. Plugin Akismet will be used. Go to your WordPress login page. This will look like the following: myw…

820 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