Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

multiline document.write or better method

Posted on 2000-03-15
2
Medium Priority
?
361 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 200 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: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering 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

Article by: DanRollins
This article describes a JavaScript program that creates a maze made of hexagonal cells.  In Part 2 (http://www.experts-exchange.com/Programming/Languages/Scripting/JavaScript/A_7850-Hex-Maze-Part-2.html), we'll extend the program by adding a depth-…
This article demonstrates how to create a simple responsive confirmation dialog with Ok and Cancel buttons using HTML, CSS, jQuery and Promises
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…

715 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