Solved

multiline document.write or better method

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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

In my daily work (mainly using ASP.net), I need to write a lot of JavaScript code. One of the most repetitive tasks I do are the jQuery Ajax calls. You know: (CODE) I don't know if for you it's the same, but for me is soooo tedious to write the …
In Part 1 (http://www.experts-exchange.com/Programming/Languages/Scripting/JavaScript/A_7849-Hex-Maze.html) we covered the hexagonal maze basics -- how the cells are represented in a JavaScript array and how the maze is displayed.  In this part, we'…
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…

912 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

20 Experts available now in Live!

Get 1:1 Help Now