PDA

View Full Version : script in iframe not showing in ff



yaaraer
12-16-2006, 09:53 PM
i got a script that i know is cross-browser inside an aspx page loaded in an iframe in another page loaded in an iframe.
the script is a countdown script that uses document.write to show the data and setTimeout to run the script every second.
the problem is that it displays in ie but not in ff though the script itself does work with both.
more so - the date to count to is generated dynamically like this:


<%
Response.Write("<script language='javascript' type='text/javascript'>");
Response.Write("var timerEnd = new Date(Date.UTC("+Request.QueryString["Year"]+","+Request.QueryString["Month"]+","+Request.QueryString["Day"]+", 0, 0, 0))");
Response.Write("</script>");
%>

just b4 the script tag.
any ideas?
p.s. i use the strict doctype.

jscheuer1
12-17-2006, 06:49 AM
Your asp code wasn't working in either browser here. This worked in both:


<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html>
<head>
<title></title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<%
Response.Write("<script type='text/javascript'>")
Response.Write("var timerEnd = new Date(Date.UTC("+Request.QueryString("Year")+","+Request.QueryString("Month")+","+Request.QueryString("Day")+", 0, 0, 0))")
Response.Write("</script>")
%>
<script type="text/javascript">
alert(timerEnd);
</script>
</head>
<body>

</body>
</html>

yaaraer
12-17-2006, 07:21 AM
well - i tried what u wrote (with the round brackets) but that doesn't even load.
I can only see now the static text, not the changing text.
This is the content of my TimeTo.aspx:


<%@ Page language="c#" Codebehind="TimeTo.aspx.cs" AutoEventWireup="false" Inherits="Site.TimeToW2" %>
<!doctype html public "-//w3c//dtd html 4.01//en" "http://www.w3.org/tr/html4/strict.dtd">
<HTML>
<HEAD>
<title>TimeToW</title>
<meta content="Microsoft Visual Studio .NET 7.1" name="GENERATOR">
<meta content="C#" name="CODE_LANGUAGE">
<meta content="VBScript" name="vs_defaultClientScript">
<meta content="http://schemas.microsoft.com/intellisense/ie5" name="vs_targetSchema">
<LINK title="Blue" href="Blue.css" type="text/css" rel="stylesheet"
<script src="styleswitch.js" type="text/javascript"></script>
<%
Response.Write("<script type='text/javascript'>");
Response.Write("var timerEnd = new Date(Date.UTC("+Request.QueryString["Year"]+","+Request.QueryString["Month"]

+","+Request.QueryString["Day"]+", 0, 0, 0))");
Response.Write("</script>");
%>
<script language="javascript">
function startTimer()
{
var DSTAdjust = 0;
var oneMinute = 1000 * 60;
var oneDay = oneMinute * 60 * 24;
var expired = '0';
time = new Date();
if (time.getTime() < timerEnd.getTime())
{
DSTAdjust = (timerEnd.getTimezoneOffset( )/60) * -1;
DSTAdjust = DSTAdjust*oneMinute*60;
var diff = timerEnd.getTime( ) - time.getTime( ) - DSTAdjust;

var hours = Math.floor(diff/(60*oneMinute));
var minutes = Math.floor(diff/oneMinute) % 60;
var seconds = Math.floor(diff/1000) % 60;
}
else
{
if (time.getDate() > timerEnd.getDate())
{
expired = '2';
}
else
{
expired = '1';
}
}
switch (expired)
{
case '0':
{

document.getElementById('hours1').innerHTML = Math.floor(hours/10);
document.getElementById('hours0').innerHTML = hours % 10;

document.getElementById('mins1').innerHTML = Math.floor(minutes/10);
document.getElementById('mins0').innerHTML = minutes % 10;

document.getElementById('secs1').innerHTML = Math.floor(seconds/10);
document.getElementById('secs0').innerHTML = seconds % 10;

setTimeout('startTimer()', 100);
break;
}
case '1':
{
document.getElementById('mins1').innerHTML = "<big>היום</big>";
break;
}
case '2':
{
document.getElementById('mins1').innerHTML = "<big>עבר</big>";
break;
}
default:
{
break;
}
}
}

document.write("<table id='timer' align='center' class='timer' cellpadding='0' cellspacing='0'>"+
"<tr><td id='hours1'></td><td id='hours0'></td><td>&nbsp;</td><td id='mins1'></td><td id='mins0'></td><td>&nbsp;</td><td

id='secs1'></td><td id='secs0'></td></tr>"+
"<tr class='labels'><td colspan='2' align='center'>hours</td><td>&nbsp;</td><td colspan='2'

align='center'>mins</td><td>&nbsp;</td><td colspan='2' align='center'>secs</td></tr></table>");
window.onload=startTimer;
</script>
</HEAD>
<BODY>
</BODY>
</HTML>

jscheuer1
12-17-2006, 08:13 AM
I tried the asp code out on an asp enabled server. Perhaps your server is different. Or, were you even trying this on a server? Also, this:



<%@ Page language="c#" Codebehind="TimeTo.aspx.cs" AutoEventWireup="false" Inherits="Site.TimeToW2" %>


changes the server side language, I believe, from VBscript to c#, which would explain at least why you were having trouble with my asp/VBscript code. This really isn't a javascript question, you should go to the asp section or perhaps to another asp forum. You do need someone with some javascript knowledge (I have tons of that), but also with c# (not me) and asp (I only have some asp experience).

Sorry I can't be of much more help. If I had a link to the live page, I might be able to pick up on a few things from the generated source - that would be in javascript and HTML. I'm real good with those.

jscheuer1
12-17-2006, 09:53 AM
Another thing occurs to me, looking at your code. Try getting rid of one or more of these meta tags in turns:



<meta content="C#" name="CODE_LANGUAGE">
<meta content="VBScript" name="vs_defaultClientScript">
<meta content="http://schemas.microsoft.com/intellisense/ie5" name="vs_targetSchema">

If doing that fixes it fine. On the other hand, if doing that breaks it in IE, that probably means that some portion of your client side code is IE only.

jscheuer1
12-18-2006, 03:32 AM
I know I may have lost you here but, another thought occurs to me. The server side of this script has to execute identically, regardless of the browser. So, it would have to be something with the way that FF is interpreting the generated and/or the literal code on the client side.