Solved

multiline document.write or better method

Posted on 2000-03-15
2
359 Views
Last Modified: 2008-03-10
I'm trying to dynamiclly build my web pages for ie and netscape users so that the page is constructed differently for each at the time the page loads, depending on the browser, so far, this is what I'm doing ....

<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=windows-1252">
<title>Browser Check ...</title>
<link rel="stylesheet" href="styles/url.css">
<script language="javascript">
     var uagent;uagent = navigator.userAgent;
     if (uagent.substring(25,29)=="MSIE" && uagent.charAt(30) > 2)
       document.write("<META HTTP-EQUIV='Refresh' CONTENT='0; URL=http://fibdev.com/ie/'>")
     else
       document.write("<META HTTP-EQUIV='Refresh' CONTENT='0; URL=http://fibdev.com/non-ie/'>")
</script>
</head>
</html>

I've tryed to substitute the "document.write" line with html for my ie site code, but I get a syntax error.  I've tryed doing multiple document.write's, but to no avail.  Is there a better way to do this than the approch I'm attempting?
0
Comment
Question by:fibdev
[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
2 Comments
 
LVL 75

Accepted Solution

by:
Michel Plungjan earned 50 total points
ID: 2619526
No need for meta tags to redirect:

<script language="javascript">
var ver = navigator.appVersion;
if (ver.indexOf("MSIE") !=-1 && parseInt(ver) > 2)
   window.location='http://fibdev.com/ie/';
else window.location='http://fibdev.com/non-ie/';
</script>

if you want the page to be written, watch the quotes:

<script language="javascript">
var ver = navigator.appVersion;
IE = (ver.indexOf("MSIE") !=-1 && parseInt(ver) > 2)
var text = "";
if (IE) {
   text += '<TIT'+'LE>IE specific page</TIT'+'LE>';
   text += '<BO'+'DY TEXT="#FFFFFF" BACKGROUND="#000000">';
   text += '<H3>Hello and welcome to my IE page </H3>';
   text += '</BO'+'DY>';
}
else {
   text += '<TIT'+'LE>IE specific page</TIT'+'LE>';
   text += '<BO'+'DY TEXT="#FFFFFF" BACKGROUND="#000000">';
   text += '<H3>Hello and welcome to my non-IE page </H3>';
   text += '</BO'+'DY>';
}

document.write(text);
</script>


Michel
0
 
LVL 3

Author Comment

by:fibdev
ID: 2621675
Thanks ...
0

Featured Post

Get 15 Days FREE Full-Featured Trial

Benefit from a mission critical IT monitoring with Monitis Premium or get it FREE for your entry level monitoring needs.
-Over 200,000 users
-More than 300,000 websites monitored
-Used in 197 countries
-Recommended by 98% of users

Question has a verified solution.

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

I've been trying to accomplish this for a while and it just struck me yesterday how to accomplish this task. I have done searches all over the internet looking for ways to email pages from my applications and finally I have done it!!! Every single s…
The task A number given should be formatted for easy reading by separating digits into triads. Format must be made inline via JavaScript, i.e., frameworks / functions are not welcome. So let’s take a number like this “12345678.91¿ and format i…
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)
The viewer will learn the basics of jQuery including how to code hide show and toggles. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery…
Suggested Courses

615 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