Solved

multiline document.write or better method

Posted on 2000-03-15
2
357 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
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

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

Avoid defining the variables in the global scope; trying to define them in a local function scope. Because:   • Look-up is performed every time a variable is accessed.   • Variables are resolved backwards from most specific to least specific scope…
Today, the web development industry is booming, and many people consider it to be their vocation. The question you may be asking yourself is – how do I become a web developer?
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…

856 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