Mailing Lists: Apple Mailing Lists

Image of Mac OS face in stamp
 
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Safari: Can't Find Variable: window, Date (Using Nested Framesets)




I'm using a frameset with a hidden frame to be able to hold onto my objects as the content of the window changes. If the bottom frame is itself a frameset and I load a new page in that bottom frame, I get the following Javascript console error when referring to "window" and when trying to create a new Date for example.


Can't find variable: window
undefined
Can't find variable: Date
undefined

Safari 1.3 (v312)
Does not occur when running in Firefox 1.0.4

Anyone have a solution? Is there any other way to hold onto Javascript objects when loading a new page? (not cookies, I didn't think they can hold objects, right?)

Thanks,
Philip Weaver

------------------------------------------------------------------------ -----
index.html
------------------------------------------------------------------------ -----
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">


<html>
	<head>
		<title>Can't Find Variable Test</title>
	</head>
	<frameset cols="50, *">
		<frame src="top.html">
		<frame src="innerFrameset.html">
	</frameset>
</html>

------------------------------------------------------------------------ -----
innerFrameset.html
------------------------------------------------------------------------ -----
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html>
<head>
<title>Can't Find Variable Test</title>
</head>
<frameset rows="50, *">
<frame src="top.html">
<frame src="bottom.html">
</frameset>
</html>
------------------------------------------------------------------------ -----
top.html
------------------------------------------------------------------------ -----
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html>
<head>
<title></title>
</head>
<body></body>
</html>
------------------------------------------------------------------------ -----
bottom.html
------------------------------------------------------------------------ -----
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html>
<head>
<title></title>
<script language="Javascript" src="Application.js"></script>
</head>
<body onload="window.top.application = new Application();">
<form>
<input type="button" value="window.top.application.showAlert();" onclick="window.top.application.showAlert();"><br/>
<input type="button" value="window.alert(window.top.application.getString())" onclick="window.alert(window.top.application.getString());"><br/>
<input type="button" value="window.alert(window.top.application.getDate())" onclick="window.alert(window.top.application.getDate());"><br/>
<input type="button" value="Go to bottom2.html" onclick="window.top.frames[1].location.href='bottom2.html';">
</form>
</body>
</html>
------------------------------------------------------------------------ -----
bottom2.html
------------------------------------------------------------------------ -----
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html>
<head>
<title></title>
<script language="Javascript" src="Application.js"></script>
</head>
<body>
<form>
<input type="button" value="window.top.application.showAlert();" onclick="window.top.application.showAlert();"><br/>
<input type="button" value="window.alert(window.top.application.getString())" onclick="window.alert(window.top.application.getString());"><br/>
<input type="button" value="window.alert(window.top.application.getDate())" onclick="window.alert(window.top.application.getDate());"><br/>
</form>
</body>
</html>
------------------------------------------------------------------------ -----
Application.js
------------------------------------------------------------------------ -----


function Application() {
	
	this.sValue = null;
	
	this.init = Application_Init;
	this.showAlert = Application_ShowAlert;
	this.getString = Application_GetString;
	this.getDate = Application_GetDate;
	
	this.init();
}

function Application_Init() {
	this.sValue = "I am a string";
}

function Application_ShowAlert() {
	window.alert("Alert called from inside Application object");
}

function Application_GetString() {
	return this.sValue;
}

function Application_GetDate() {
	return new Date();
}

_______________________________________________
Do not post admin requests to the list. They will be ignored.
Web-dev mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/web-dev/email@hidden

This email sent to email@hidden


Visit the Apple Store online or at retail locations.
1-800-MY-APPLE

Contact Apple | Terms of Use | Privacy Policy

Copyright © 2007 Apple Inc. All rights reserved.