View Full Version : Stylesheet problem in Netscape 4.75

04-14-2005, 03:37 AM
I have a script that will display a person's contact info in a popup window when their name is clicked. The popup window contains a 'Previous' and 'Next' button that when clicked will display the info for the previous or next person in the array of names.

The problem is that for some reason this line: '<link rel="stylesheet" href="style.css">\n' + is causing the previous and next buttons to not work in Netscape 4.75. If I take out that line it works fine, but I lose the formatting. Am I not writing this line correctly? How can I not lose the formatting?

Here is the entire code:

<script language="Javascript">
var employees = [];
employees[0] = ["James","Smith", "555-1000", "james.smith@spam.net"];
employees[1] = ["Jean","Smith", "555-2000", "jean.smith@spam.net"];
employees[2] = ["John","Smith", "555-3000", "john.smith@spam.net"];

var currentEmp = -1;
function GetNext(xDir) //xDir should be 1 or -1
currentEmp += xDir;
else if(currentEmp<0)currentEmp=employees.length - 1;

var newwin = false;
function showEmployee(key)
var emp = employees[key];
currentEmp = key;
if(!newwin || newwin.closed){
newwin = window.open('','','top=0,left=0,width=400,height=300');
var html =
'<html>\n' +
'<head>\n' +
'<title>' + emp[1].toUpperCase() + ', ' + emp[0].toUpperCase() + '</title>\n' +
'<link rel="stylesheet" href="style.css">\n' +
'</head>\n' +
'<body>\n' +
'<table>\n' +
'<tr><td>' + emp[0] + ' ' + emp[1] + '</td></tr>\n' + //First
'<tr><td>' + emp[2] + '</td></tr>\n' + //Phone
'<tr><td><a href="mailto:' + emp[3] + '">' + emp[3] + '</a></td></tr>\n' + //Email
'</table>\n' +
'<form>\n' +
'<input type="button" value="Previous" onclick="window.opener.GetNext(-1);">' +
'<input type="button" value="Next" onclick="window.opener.GetNext(1);">\n' +
'</form>\n' +
'</body>\n' +

alert('Employee not found.');
return false;

<script language="JavaScript" type="text/JavaScript">
function MM_reloadPage(init) { //reloads the window if Nav4 resized
if (init==true) with (navigator) {if ((appName=="Netscape")&&(parseInt(appVersion)==4)) {
document.MM_pgW=innerWidth; document.MM_pgH=innerHeight; onresize=MM_reloadPage; }}
else if (innerWidth!=document.MM_pgW || innerHeight!=document.MM_pgH) location.reload();

function MM_findObj(n, d) { //v4.01
var p,i,x; if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
if(!x && d.getElementById) x=d.getElementById(n); return x;

function MM_showHideLayers() { //v6.0
var i,p,v,obj,args=MM_showHideLayers.arguments;
for (i=0; i<(args.length-2); i+=3) if ((obj=MM_findObj(args[i]))!=null) { v=args[i+2];
if (obj.style) { obj=obj.style; v=(v=='show')?'visible':(v=='hide')?'hidden':v; }
obj.visibility=v; }


<table border=0 width=300>
<td><a href="#" onclick="MM_showHideLayers('A','','show')">A</a></td>

<div id="A" class="text" style="position:absolute; left:100px; top:50px; z-index:1; visibility: hidden;">
<ul type="square">
<li><a href="#" onclick="return showEmployee(0)">Smith, James</a>
<li><a href="#" onclick="return showEmployee(1)">Smith, Jean</a>
<li><a href="#" onclick="return showEmployee(2)">Smith, John</a>


04-14-2005, 11:16 AM
try puting each of your lines in the "html" string into an array, and then loop through the array, sorta like so:

with (newwin.document)
aHtml = new Array();
aHtml[0] = '<head>';
aHtml[1] = '<title>' + emp[1].toUpperCase() + ', ' + emp[0].toUpperCase() + '</title>';
aHtml[2] = '<link rel="stylesheet" href="style.css">';
aHtml[3] = '</head>';

for (var i=0; i<aHtml.length; i++) write(aHtml[i]+"\n");


not necessarily sure if that will help your problem, but it's a more efficient way of writing to a document, IMHO. one advantage is that you can change the contents of the output easier by simply changing any key of the array.

04-14-2005, 11:39 AM
for (var i=0; i<aHtml.length; i++) write(aHtml[i]+"\n");

You don't need to loop to output the contents of the array since the toString method of Array is called automatically when you call the array itself.

write(aHtml); //the same with write(aHtml.toString());

Or if you want the newlines after each element: