I have written a javascript code but it works only in IE and chrome and not in firefox. I mean, when I click the button to call the function, in firefox I see no action (!)
On the other hand the background image is displayed only in firefox and not in IE.
What is the source of these inconsistencies?
18 2682
Browsers don't all behave the same, but it usually helps to code to standards where possible. Post your code, otherwise we'd have no idea what might be causing the problem.
I thought it is a general problem. Here is the code. Thanks, - <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
-
<html xmlns="http://www.w3.org/1999/xhtml">
-
<head>
-
<title>Untitled Document</title>
-
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" >
-
<style type="text/css">
-
<!--
-
.style2 {font-size: 18px}
-
body {
-
background-image: url(background.jpg);
-
}
-
-->
-
</style>
-
</head>
-
-
<body>
-
<script language='javascript' type='text/javascript'>
-
function calc() {
-
<!-- main code -->
-
-
</script>
-
-
-
<form id="form1" name="form1" method="post" action="">
-
<p>
-
<label>
-
-
<div align="left">
-
<fieldset>
-
<legend><span class="style2">Environment</span></legend>
-
<div align="left">
-
<input type="radio" name="Environment" value="1" id="Environment_0" >
-
<span class="style2">Residential</span> </div>
-
<div align="left"><input type="radio" name="Environment" value="2" id="Environment_1" >
-
<span class="style2">Official</span></div>
-
<div align="left"><input type="radio" name="Environment" value="3" id="Environment_2" >
-
<span class="style2">Industrial</span></div>
-
</fieldset>
-
<p align="left" class="style2">Please insert the following information:</p>
-
-
<label>
-
<div align="center" class="style2">Velocity (m/s)
-
<select name="V" id="V">
-
<option selected >Very low</option>
-
<option>Low</option>
-
<option>Medium</option>
-
<option>High</option>
-
<option>Very high</option>
-
</select>
-
Garment Insulation (clo)
-
<select name="C" id="C">
-
<option selected="selected">Low</option>
-
<option>Medium</option>
-
<option>High</option>
-
</select>
-
</div>
-
<span class="style2">
-
</label>
-
<label>
-
</span>
-
<div align="center" class="style2">Relative humidity (%)
-
<input name="R" type="text" id="R" size="8" >
-
  Metabolic Heat Generation (met)
-
<select name="M" id="M">
-
<option selected="selected">Low</option>
-
<option>Medium</option>
-
<option>High</option>
-
</select>
-
</div>
-
</label>
-
<label></label>
-
<label>
-
-
<div align="left">
-
<p align="center">
-
<input name="C2" type="button" id="C2" value="Calculate" onclick="calc()" />
-
</p>
-
</div>
-
</label>
-
<label>
-
<div align="left">
-
<p align="center">Temperature (C)
-
<input name="T" type="text" id="tem" size="10" maxlength="5" >
-
</p>
-
</div>
-
</label>
-
<label>
-
-
<div align="left">
-
<p align="center">
-
<input name="E" type="submit" id="E" onclick="window.close()" value="Exit" >
-
</p>
-
</div>
-
</label>
-
<p> </p>
-
<p> </p>
-
</body>
-
</html>
If it's the calc() function that's not working, I'll need to see that. Can you post that using code tags please.
It is also lengthy. thanks, -
var k = 0;
-
if ( form1.Environment[0].checked ) {
-
k = 1;
-
}
-
else if ( form1.Environment[1].checked )
-
k = 2;
-
else if ( form1.Environment[2].checked )
-
k = 3;
-
-
var n = 0;
-
-
<!-- reading velocity combo box -->
-
var zz = form1.V.selectedIndex;
-
switch ( zz ) {
-
case 0:
-
var v = 0.1;
-
break;
-
case 1:
-
var v = 0.2;
-
break;
-
case 2:
-
var v = 0.3;
-
break;
-
case 3:
-
var v = 0.5;
-
break;
-
case 4:
-
var v = 1.5;
-
break;
-
}
-
-
var i = form1.M.selectedIndex;
-
var j = form1.C.selectedIndex;
-
-
switch ( k ) {
-
case 1:
-
switch ( i ) {
-
case 0:
-
var met = 0.7;
-
break;
-
case 1:
-
var met = 1.2;
-
break;
-
case 2:
-
var met = 2.4;
-
break;
-
case 0:
-
var met = 0.7;
-
break;
-
}
-
switch ( j ) {
-
case 0:
-
var clo = 0.38;
-
break;
-
case 1:
-
var clo = 0.5;
-
break;
-
case 2:
-
var clo = 0.9;
-
break;
-
}
-
break;
-
case 2:
-
switch ( i ) {
-
case 0:
-
var met = 1.0;
-
break;
-
case 1:
-
var met = 1.4;
-
break;
-
case 2:
-
var met = 2;
-
break;
-
}
-
switch ( j ) {
-
case 0:
-
var clo = 0.7;
-
break;
-
case 1:
-
var clo = 1.0;
-
break;
-
case 2:
-
var clo = 2;
-
break;
-
}
-
break;
-
case 3:
-
switch ( i ) {
-
case 0:
-
var met = 2.0;
-
break;
-
case 1:
-
var met = 3.0;
-
break;
-
case 2:
-
alert ( "wrong" );
-
break;
-
}
-
switch ( j ) {
-
case 0:
-
var clo = 0.7;
-
break;
-
case 1:
-
var clo = 1.4;
-
break;
-
case 2:
-
var clo = 2.5;
-
break;
-
}
-
break;
-
}
-
-
var hc = 12.1 * Math.pow(v, 0.5);
-
var Rcl = clo * 0.155;
-
var M = met * 58.1;
-
var W = 0.05 * M;
-
if ( clo > 0.5 )
-
var fcl = 1.05 + 0.1 * clo;
-
else
-
var fcl = 1.0 + 0.2 * clo;
-
-
var hum = parseFloat(form1.R.value);
-
var Tcl1 = -10.0;
-
var Tcl2 = 40.0;
-
var T = 5.0;
-
var TemOpt = 5.0;
-
var dif = 100;
-
-
for ( z = 1; z <= 1000; z++ ) {
-
var Pt = Math.exp(16.6536 - 4030.183 / (T + 235.0));
-
var Pa = hum * 10 * Pt;
-
var Tcl = root(Tcl1, Tcl2, M, W, fcl, hc, Rcl, T);
-
var l = (M - W)
-
var PMV = (0.303 * Math.exp(-0.036 * M) + 0.028) * l;
-
if (Math.abs(Math.abs(PMV) - 0.5) < dif) {
-
var TemOpt = T;
-
dif = Math.abs(Math.abs(PMV) - 0.5);
-
}
-
T = T + 0.03;
-
-
}
-
form1.tem.value = TemOpt;
-
}
-
-
function root( Tcl1, Tcl2, M, W, fcl, hc, Rcl, T ) {
-
while (Math.abs(f(M, W, fcl, hc, Rcl, Tcl1, T) >= 0.001 )) {
-
var Tcl3 = Tcl2 - f(M, W, fcl, hc, Rcl, Tcl2, T) - f(M, W, fcl, hc, Rcl, Tcl1, T);
-
-
if (f(M, W, fcl, hc, Rcl, Tcl3, T) * f(M, W, fcl, hc, Rcl, Tcl1, T) < 0.0)
-
var Tcl1 = Tcl3;
-
else
-
var Tcl2 = Tcl3;
-
}
-
return Tcl3;
-
}
-
-
function f(M, W, fcl, hc, Rcl, Tcl, T) {
-
var x = 35.7 - 0.028 * (M - W) - Rcl * (0.0000000396 * fcl * (Math.pow(Tcl + 273, 4) - Math.pow(T + 273, 4)) + fcl * hc * (Tcl - T)) - Tcl;
-
return x;
-
}
-
I've not checked the rest of it, but the first problem I notice is the reference to form1 in the global scope. That is incorrect. Either use - document.forms["form1"]
-
// or
-
document.form1
-
// or
-
document.getElementById("form1")
Thanks, That worked for clac(), but the "exit" button reset the form. It does not show a window to confirm for close.
The original Exit function is: - <input name="E" type="submit" id="E" onclick="window.close()" value="Exit" >
With your cue, it has to be document.form1.window.close(), but that does not work either.
Also what about the problem of backgound image. It is shown in firefox but not in IE (!)
document.form1.window.close() would be incorrect. window.close() only works on windows opened using JavaScript. If this is in the original browser window, it won't work. Use it in a pop-up window opened using window.open().
Sorry, did not understand what you said... :(
When you open the browser and visit a web page, that is the browser you opened. Now, on that web page, when you click a button, it opens a new window. This window has been opened using JavaScript, so can be closed using JavaScript (window.close()) whereas the previous browser window cannot.
yes. In this site, I saw a solution for that. There should be a manual close function and in that, first the window has to be opened and then call the close function. An interesting thing is that "dom.allow_scripts_to_close_windows" in "about :config" (firefox) has to be 'true'. Thanks for the reference.
How about the background image? it works in firefox but not in IE (!)
Yes, I've seen that hack, but it doesn't work in all browsers (for obvious reasons).
As for the background image, it's a CSS problem, so ask in the HTML/CSS forum.
Is it possible to change a value in about:config (firefox) automatically? I mean when the page is loaded, with a javascript function I change "dom.allow_scripts_to_close_windows". If it is not possible, then I have to write a notice at the end of the page and alert the user that "exit" function may not work in firefox
I doubt that. it would be too much a security issue. (would you like a website changing your browser settings?)
Why do you even need the Exit function? It'd make sense if you'd opened a window, but in the original browser window, there's no need to close it.
gits 5,390
Expert Mod 4TB @mahmoodn
it would work but not silently ... the user has to confirm that change and so you cannot rely on that ... here is a link for the usage of the mozilla PrivilegeManager ...
kind regards
After my last post, I thought it is not suitable to change someones settings in an embedded manner.
I think there is no need for close button. The tab has a close button for itself.
Thanks,
Yes, that's more like it. No need for tricks and hacks for something which doesn't give any/much benefit.
for a comparison of window.close in all (latest) browsers. - opera 9.6 will allow it. i dont know if that can be changed.
- safari and chrome wont whatsoever. as with opera i dont know if it can be changed.
- firefox3 wont allow it but will if changed in config
- IE7 will show a warning messagebox and will ask if its ok to continue
- for IE8 i have no idea but i guess the same as IE7
but as said, window.close is useless
Sign in to post your reply or Sign up for a free account.
Similar topics
by: Howard Kaikow |
last post by:
Yesterday, I decided to try Firefox. I've encountered a behavior that is
either a bug in Firefox or a bug in my Javascript code. I'll try to explain
the problem, hoping that this newsgroup can...
|
by: BrianP |
last post by:
Hi,
I have had to invent a work-around to get past what looks like a
JavaScript bug, the malfunctioning Perl-like JavaScript array functions
including SPLICE() and UNSHIFT().
I have boiled it...
|
by: John Smith |
last post by:
I am using IE 6.0
from
http://www.javaworld.com/javaworld/jw-07-1996/jw-07-javascript-p2.html
I gather that
"If you need to test a number of command lines, you can reduce the
keystrokes by...
|
by: chrisdude911 |
last post by:
how do i add video into a javascript web page with my own custom
buttons?
|
by: David McNerney |
last post by:
Would anyone be able to tell me why I get an error in FireFox 1.5.0.1
for MacOSX when I type some text and hit Enter in the following form:
<html>
<body>
<form action="http://example.com"...
|
by: lmarceglia |
last post by:
Hi,
I have this website that doesn't work in Firefox 1.5:
www.pianetaluca.com
The HTML source is:
<TITLE>PianetaLuca</TITLE>
</HEAD>
|
by: minnesotti |
last post by:
Hi there,
I subscribed to a photographic pictures-hosting website which is heavy
on JavaScript. My preferred latest browser Mozilla Firefox does not
work with it -- no pictures are displayed and...
|
by: Matt Kruse |
last post by:
http://news.zdnet.com/2100-1009_22-6121608.html
Hackers claim zero-day flaw in Firefox
09 / 30 / 06 | By Joris Evers
SAN DIEGO--The open-source Firefox Web browser is critically flawed in...
|
by: Eric |
last post by:
I have a user of a web application written in Java/JSP that is unable
to login to the site simply because certain links on the page do not
run when they are clicked. Other popups using Javascript...
|
by: emmanuelkatto |
last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud.
Please let me know.
Thanks!
Emmanuel
|
by: BarryA |
last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
|
by: nemocccc |
last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
|
by: Hystou |
last post by:
There are some requirements for setting up RAID:
1. The motherboard and BIOS support RAID configuration.
2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
|
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers,...
|
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
| |