tweaker
VIP Member
tweaks gf said:I've created this script and it works fine in Explorer; the information you put in the form is written to the new window. My problem is that the information isn't written to the new window if you use Firefox. The new window is just blank!
What do I have to change to make the script compatible with both browsers?
(I have to use xhtml.)
Code as follows:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "DTD/xhtml1-transitional.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"/>
<script language="JavaScript" type="text/javascript">
<!--Begin hiding
function opennew() {
var mywindow= window.open('','','height=280,width=450,status=0,menubar=0,scrollbars=0,resizable=1');
var bgcolor= VisitKort.backcolor.options[VisitKort.backcolor.selectedIndex].value
var fontcolor= VisitKort.fontcolor.options[VisitKort.fontcolor.selectedIndex].value
var myfont= VisitKort.myfont.options[VisitKort.myfont.selectedIndex].value
mywindow.document.write('<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"><html><head><title>Visitkort</title></head><body bgcolor="'+bgcolor+'"><font face="'+myfont+'" size="7" color="'+fontcolor+'">' +VisitKort.company.value+ '</font><br /><font face="'+myfont+'" size="5" color="'+fontcolor+'">' +VisitKort.firstname.value+ ' ' +VisitKort.lastname.value+ '</font><br /><font face="'+myfont+'" size="3" color="'+fontcolor+'">' +VisitKort.title.value+ '</font><br /> <br /><font face="'+myfont+'" size="5" color="'+fontcolor+'">Telephone: ' +VisitKort.tele.value+ '</font><br /><font face="'+myfont+'"size="3" color="'+fontcolor+'">E-post: ' +VisitKort.email.value+ '</font><br /> <br /><hr /><form><input type="button" value="Skriv ut" onClick="window.print()" /></form></body></html>');
mywindow.document.close();
}
//Stop hiding-->
</script>
</head>
<body>
<table border="1" width="600" align="center" cellpadding="20">
<tr>
<td align="center"><p class="center"><strong>Business card</strong></p>
<center>
<form name="VisitKort" action="*">
<table border="0">
<tr>
<td>Company</td>
<td><input type= "text" name="company" size="20" /></td>
</tr>
<tr>
<td>Last name</td>
<td><input type= "text" name="lastname" size="20" /></td>
</tr>
<tr>
<td>First name</td>
<td><input type= "text" name="firstname" size="20" /></td>
</tr>
<tr>
<td>Title</td>
<td><input type= "text" name="title" size="20" /></td>
</tr>
<tr>
<td>Phone number</td>
<td><input type= "text" name="tele" size="20" /></td>
</tr>
<tr>
<td>E-mail</td>
<td><input type= "text" name="email" size="20" /></td>
</tr>
<tr>
<td>Background color</td>
<td>
<select name="backcolor">
<option value="#66CCFF">Light blue</option>
<option value="#FFFF99">Light yellow</option>
<option value="#FFFFFF">White</option>
<option value="#99FFFF">Turquoise</option>
</select>
</td>
</tr>
<tr>
<td>Font color</td>
<td>
<select name="fontcolor">
<option value="000000">Black</option>
<option value="3333FF">Blue</option>
<option value="FF0000">Red</option>
<option value="336666">Dark green</option>
</select>
</td>
</tr>
<tr>
<td>Font</td>
<td>
<select name="myfont">
<option value="Verdana">Verdana</option>
<option value="Arial">Arial</option>
<option value="Tahoma">Tahoma</option>
<option value="Impact">Impact</option>
</select>
</td>
</tr>
<tr>
<td colspan="2">
<br />
<input type= "reset" value="Reset" onclick="reset" />
<input type= "button" name="submit" value="Create business card" onclick=" opennew()" /></td>
</tr>
</table>
</form>
</center>
</td>
</tr>
</table>
</body>
</html>
/Thank you.