Solved

IE and Netscrape....

Posted on 2000-03-21
6
199 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
Comment Utility
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
Comment Utility
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
Comment Utility
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
How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

 
LVL 1

Expert Comment

by:damianosky
Comment Utility
<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
Comment Utility
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
Comment Utility
Thank you .... your input has been most helpful
0

Featured Post

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

Suggested Solutions

Turn A Profile Picture Into A Cartoon Using Photoshop And Illustrator This tutorial will teach you how to make a cartoon style image out of a regular picture. I have tried to keep the tutorial as simple as possible. I used Adobe CS4 for this tuto…
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.
The purpose of this video is to demonstrate how to make a WordPress Site faster and smaller in size by cleaning up the database. This will be demonstrated using a Windows 8 PC. Plugin WP Optimize will be used. Go to your WordPress login page. T…
The purpose of this video is to demonstrate how to exclude a particular blog category from the main blog page. This is can be used when a category already has its own tab, or you simply want certain types of posts not to show up on the main blog. …

763 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

Need Help in Real-Time?

Connect with top rated Experts

8 Experts available now in Live!

Get 1:1 Help Now