|
-
I was hoping someone could take a look at this code. It does what I want in IE but, Netscape is not reading it.
<html>
<head>
<title>Resolution</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<SCRIPT LANGUAGE="JavaScript">
<!--
var url800x600= "http://cecpeople.bu.edu/ksulliva/fratellos/index2.htm";
var url1024x768= "http://cecpeople.bu.edu/ksulliva/fratellos/index1.htm";
if ((screen.width == 800) && (screen.height == 600))
{
window.location.href= url800x600;
}
else
{
window.location.href = url1024x768;
}
//-->
</SCRIPT>
</head>
<body bgcolor="#000000">
</body>
</html>
-
worked for me. what's it not doing?
-
Originally posted by edeveloper
worked for me. what's it not doing?
I have a mac w/virtual pc. When I view my site in Netscape in v. pc it calls the larger res. It works fine in IE in v. pc. I wasn't sure if the problem extended past virtual pc. What platform and version of ns are you using? Thanks for your help.
If you could go to this site and let me know what url it goes to, either index1 or index2 and what browser you are using, I would greatly appreciate it.
http://cecpeople.bu.edu/ksulliva/fratellos/index.htm
Thank you.
-
netscape compliant
<html>
<head>
<title>Resolution</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<script language="JavaScript1.2">
if (screen.width==800||screen.height==600)
window.location.replace("http://cecpeople.bu.edu/ksulliva/fratellos/index2.htm")
else if (screen.width==1024||screen.height==768)
window.location.replace("http://cecpeople.bu.edu/ksulliva/fratellos/index1.htm")
else
window.location.replace("http://www.flashkit.com")
</script>
</head>
<body bgcolor="#000000">
</body>
</html>
-
Can't thank you enough...that worked. Do I have to manipulate all the javaScript to work in Netscape? I'm having another problem with a form validation, it works 100% in IE but NS just submits the form without validating anything. If you could take a look, I'd be very grateful.
<script language="JavaScript">
function validate()
{
if (reservation.fname.value =="")
{
alert("Please provide your first name.")
reservation.fname.focus()
return false
}
if (reservation.lname.value =="")
{
alert("Please provide your last name.")
reservation.lname.focus()
return false
}
if (reservation.time.value =="")
{
alert("Please enter reservation time.")
reservation.time.focus()
return false
}
if (reservation.number.value =="")
{
alert("Please enter number in party.")
reservation.number.focus()
return false
}
return true
}
</script>
-
Hi
I would need to look at the whole script to see exactly how you validate but Im guessing netscape ignores the function validate() at some point. What you should be looking to do is force validation on each change onChange=validate(somenamevariable,somevaluevariab le) of the fields. Regarding scripting cross browser well to be honest it gets more and more difficult and I think its really fragmenting the web. My advice either read up on scripting in ns, ie, opera, webtv and create several pages for each. add a sniffer script to the homepage to detect the users browser and redirect accordingly. Or alternatively jump on the flash bandwaggon. One thing which will be extremely tedious is to create a sophisticated single cross browser/ platform javascript site.
qualias
-
Hi grbarren,
some visitors might be annoyed if you care for actual screen resolution at all, rather than for current browser window.
In NS, window.innerWidth is the best one to use, in IE, body.clientWidth is a strong contender
@qualias: you are sure that (width == something) OR (height == something) is a good way to measure screen size.
Just a little bit of warning: some systems - even windoes with high-end display drivers - allow to create very non-standard screen resolutions.
Musicman
-
@Musicman
I only ammended the initial script to function as the guy wanted, nothing more ! Yes there are more factors that we must take into consideration, and indeed sniffing can in itself be quite a complex art.
-
Originally posted by qualias
@Musicman
I only ammended the initial script to function as the guy wanted, nothing more ! Yes there are more factors that we must take into consideration, and indeed sniffing can in itself be quite a complex art.
My problem is that this is my first site and I do not have a strong programming background. I'm not getting paid for this, I'm doing this to learn and Flash kit has been an incredible resource. If I get help for even one problem this was worth it, please bare with me. I created a simple resturant site that has an interactive contact page that will allow users to reserve a
table online. The form has to be valiadated to insure proper info. input. Things work fine for me on my MAC in IE5.5 but, Netscape is not reading my JavaScript. Is there something missing in my script that would make it compatible with Netscape? I realize that cross browers issues are a major problem for web developers but, what the hell do you do? As a moderate level designer I would greatly appreciate any feedback.
Here is my URL:
http://cecpeople.bu.edu/ksulliva/fratellos/index.htm
because the site is in frames here is the page I'm having problems with
http://cecpeople.bu.edu/ksulliva/fratellos/contact2.asp
and here is the code:
<HTML>
<HEAD>
<TITLE>Fratello's Ristorante</TITLE> <META HTTP-EQUIV="Content-Type"
CONTENT="text/html; charset=iso-8859-1">
<script language="JavaScript">
function init(){
if (navigator.appName=="Netscape"){
var layerRef="document.layers";
var styleRef="";
}else {
var layerRef="document.all";
var styleRef="style";
}
}
function confirm()
{
window.open("confirm.htm","_blank","width=300,heig ht=200")
}
function launchwin()
{
window.open("update2.html","_blank","width=400,hei ght=500")
}
<------THIS IS WHERE I AM HAVING THE VALIDATION PROBLEM:--------->
function validate()
{
if (reservation.fname.value =="")
{
alert("Please provide your first name.")
reservation.fname.focus()
return false
}
if (reservation.lname.value =="")
{
alert("Please provide your last name.")
reservation.lname.focus()
return false
}
if (reservation.time.value =="")
{
alert("Please enter reservation time.")
reservation.time.focus()
return false
}
if (reservation.number.value =="")
{
alert("Please enter number in party.")
reservation.number.focus()
return false
}
return true
}
</script>
</HEAD>
<BODY BGCOLOR="#000000" vlink="#999966"onLoad="init()","self.name='Main'"
onUnload="self.name=''" link="#999966" alink="#999966">
<a name="top"></a>
<div id="Layer1" style="position:absolute; width:200px; height:115px;
z-index:1; left: 0px; top: 1px">
<div id="Layer2" style="position:absolute; width:109px; height:17px;
z-index:8; left: 460px; top: 890px">
<div align="right"><font color="#999966"><a href="#top">Return </a> to
top</font></div>
</div>
<img src="f_images/contactnew2.gif" width="578" height="893">
<div id="Layer3" style="position:absolute; width:217px; height:357px;
z-index:0; left: 358px; top: 114px">
<-----------THIS IS THE FORM THAT THE VALIDATION FUNCTION IS SUPPOSED TO
VALIDATE--->
<form name="reservation" onSubmit="confirm()" >
<table width="94%" border="0" cellspacing="0" cellpadding="0"
height="350">
<tr>
<td colspan="2"><font color="#999966" size="4" face="Georgia,
Times New Roman, Times, serif"><i>Online
Reservation Request:</i></font></td>
</tr>
<tr>
<td colspan="2" height="66">
<p><font color="#999966" size="3">Please enter your first
name:</font></p>
<p>
<input type="text" name="fname" value="">
</p>
</td>
</tr>
<tr>
<td colspan="2" height="57">
<p><font color="#999966">Please enter your last name:</font></p>
<p>
<input type="text" name="lname" value="">
</p>
</td>
</tr>
<tr>
<td colspan="2" height="42">
<p><font color="#999966">Reservation time:</font></p>
<p>
<input type="text" name="time" value="">
</p>
</td>
</tr>
<tr>
<td colspan="2" height="70">
<p><font color="#999966">Number in party:</font></p>
<p>
<input type="text" name="number" value="">
</p>
</td>
</tr>
<tr>
<td width="50%" height="30">
<div align="left">
<input type="submit" name="Submit" value="Submit"
onClick="return validate()">
</div>
</td>
<td width="50%">
<div align="left">
<input type="reset" name="Submit2" value="Reset">
</div>
</td>
</tr>
</table>
</form>
<--------------------END OF FORM---------------------------->
</div>
<div id="Layer4" style="position:absolute; width:396px; height:347px;
z-index:9; left: 3px; top: 494px">
<table width="100%" border="0" cellspacing="0" cellpadding="5" >
<tr>
<td height="24">
<div align="left"><font color="#FF0707" size="6"><i><font
face="Georgia, Times New Roman, Times, serif" color="#999966" size="5">Daily
Specials </font></i></font></div>
</td>
</tr>
<tr valign="top">
<td height="5">
<hr>
</td>
</tr>
<tr valign="top">
<td height="200">
<p><b><font size="4" color="#999966">Today:</font><font size="5"
color="#999966"><%=strdate%></font></b></p>
<p><b><font size="4"
color="#999966">Soup:<%=strsoup%></font></b></p>
<p><b><font size="4"
color="#999966">Pizza:<%=strpizza%></font></b></p>
<p><b><font size="4"
color="#999966">Lunch:<%=strlunch%></font></b></p>
<p><b><font size="4" color="#999966">Dinner:
<%=strdinner%></font></b></p>
<p><b><font size="4"
color="#999966">Appetizer:<%=strappetizer%></font></b></p>
<p><b><font face="Arial, Helvetica, sans-serif" color="#FF0000"
size="2">**See
an </font><font color="#999966" size="2"><a
href="update2.html">example
</a></font><font face="Arial, Helvetica, sans-serif"
color="#FF0000" size="2">of
how the site owner is</font></b></p>
<p><font size="2"><b><font face="Arial, Helvetica, sans-serif"
color="#FF0000">
able to update daily specials through</font></b></font></p>
<p><font size="2"><b><font face="Arial, Helvetica, sans-serif"
color="#FF0000">
the use</font></b> <b><font face="Arial, Helvetica, sans-serif"
color="#FF0000">of
Active Server Pages.</font> </b></font></p>
<p> </p>
</td>
</tr>
</table>
</div>
</div>
</BODY>
</HTML>
-
Hi,
you already distinguish betwwen ns and ie at the top of the file. Add here
[netscape case]
docpath = document.layers.Layer1.document.Layer3.document.fo rms
and [ie case]
docpath = document.forms
replace reservation by docpath.reservation throughout validate() function
Musicman
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|