PDA

View Full Version : Works with IE but not with Firefox :S



Private_Guy
06-27-2007, 07:52 PM
Hi there,

I have this JavaScript which works really good with IE but not with firefox, how can I fix it to work with Firefox too?

Source:

<center><input type="submit" value="Upload!" type="submit" class="lstbox" id="upload" onclick="document.getElementById('text1').style.visibility= 'visible';">
<div id="text1" style="visibility:hidden;">
<p align="center">
<b><font size="4">
<marquee direction="right" scrolldelay="50" behavior="alternate">...</marquee></font>Uploading In Process...</b>
<b><font size="4">
<marquee direction="right" scrolldelay="50" behavior="alternate">...</marquee></font></b></p>

</center>
<HEAD>

<script type="text/javascript">
<!--
function confirmation() {
var answer = confirm("Are you sure you want to cancel your upload?")
if (answer){
alert("You have successfully cancelled your upload")
window.location = "index.php";
}
else{
alert("Your upload has not been cancelled and will be continued")
}
}
//-->
</script>
<form>
<input type="button" onclick="confirmation()" value="Cancel Your Upload?">
</div>
</form>

Thanks very much.

Best Regards,
Private_Guy

codeexploiter
06-28-2007, 03:49 AM
The code you've provided works both in IE 7 and Firefox 2.0.0.4 in similar way. Inorder to avoid some mismatches of tags in your source I've arranged them which you can see below:



<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Untitled Document</title>
<style type="text/css">

</style>
<script type="text/javascript">
function confirmation() {
var answer = confirm("Are you sure you want to cancel your upload?")
if (answer){
alert("You have successfully cancelled your upload")
window.location = "index.php";
}
else {
alert("Your upload has not been cancelled and will be continued")
}
}
</script>
</head>
<body>
<center><input type="submit" value="Upload!" type="submit" class="lstbox" id="upload" onclick="document.getElementById('text1').style.visibility= 'visible';">
<div id="text1" style="visibility:hidden;">
<p align="center">
<b><font size="4">
<marquee direction="right" scrolldelay="50" behavior="alternate">...</marquee></font>Uploading In Process...</b></font>
<b><font size="4">
<marquee direction="right" scrolldelay="50" behavior="alternate">...</marquee></font></b>
</p>
</div>
</center>
<form>
<input type="button" onclick="confirmation()" value="Cancel Your Upload?" />

</form>
</body>
</html>


It would be better if you avoid the usage of <b> and <font> tags and use CSS for them. I haven't changed your code much which can be arranged in a far better manner for example you can have a <form> tag in which you can place all the form fields (submit button & a command button) like that but the aim of mine was just to check whether it is working or not.