473,386 Members | 1,630 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,386 software developers and data experts.

cross page persistence


I need to persist some objects across page navigations, I am under the
impression that on each new page a new set of top level objects are
provided so I don't know where, how or if I can persist my own objects.
Any advice please?

TIA,
Mike W

Jul 21 '06 #1
6 1626

VisionSet wrote:
I need to persist some objects across page navigations, I am under the
impression that on each new page a new set of top level objects are
provided so I don't know where, how or if I can persist my own objects.
Any advice please?

The object I wish to persist are window objects. I create them in one
page but the user may navigate away from this page and hence I need a
central repository to store the references for access from any page a
user may browse to.

TIA
Mike W

Jul 21 '06 #2
VisionSet wrote:
VisionSet wrote:
>I need to persist some objects across page navigations, I am under the
impression that on each new page a new set of top level objects are
provided so I don't know where, how or if I can persist my own objects.
Any advice please?


The object I wish to persist are window objects. I create them in one
page but the user may navigate away from this page and hence I need a
central repository to store the references for access from any page a
user may browse to.
Hi Mike,

There is no such place (as far as I know). There are some window-tricks
that you might be able to use. See the script below:

<html>

<script type="text/javascript">
function openIfNotExist(url, name) {
win = window.open("", name, "width=300,height=200");
if ('' + win.location == "about:blank") {
win = window.open(url, name);
}
win.focus();
return win;
}

function getReferenceIfExist(name) {
// rather ugly, because it opens a window
win = window.open("", name, "width=1,height=1");
if ('' + win.location == "about:blank") {
win.close();
return null;
}
return win;
}

</script>

<body>
<input type="button" value="reference" onclick="alert('ref: ' +
getReferenceIfExist('test'));">
<input type="button" value="open or focus"
onclick="openIfNotExist('test.html', 'test');">
</body>

</html>

Both functions work cross page.

OpenIfNotExist opens a window with that URL if it doesnt exist, else it
focusses that window and returns the reference.

getReferencEIfExists returns the reference of a window. However, it must
open a window before knowing whether it already exists, so a window fill
flash before your eyes if not.

Good luck,
Vincent
Jul 21 '06 #3
Vincent van Beveren wrote:
<snip>
There is no such place (as far as I know). There are some window-tricks
that you might be able to use. See the script below:
<snip>
function openIfNotExist(url, name) {
win = window.open("", name, "width=300,height=200");
Even if the window with the corresponding name is open this will result
in it being loaded with the URL specified in the window open call
(subject to the availability of a window.open method on the UA in
question and pop-up blockers not being in operation on the client
computer). Generally a URL specified as an empty string will be taken
as 'about:blank', though not always, with alternative such as
'opera:balnk' having been previously observed in the wild.

(incidentally, code posted to Usenet should be indented with sequences
of space characters (two to four, are suggested) as any newsreader's
representation of a tab character is an unknown quantity, ranging from
zero space (no-indentation) to values equivalent to 8 spaces or
greater, making lines wrap and rendering code hard to read.)
if ('' + win.location == "about:blank") {
Having opened the window with an empty string as the first argument
this is almost certain to be true (while occasionally being false in
circumstances which are equivalent to 'about:blank').

It also seems more reasonable to be reading the - location - object's -
href -property, which is a string, than to be type-converting the -
location - object into a string by concatenating it to an empty string.

win = window.open(url, name);
<snip>

It would be more reliable, and no worse, to just pass the URL argument
into the initial call to - window.open -, as even if the URL argument
is the current URL of a page being displayed in that window the
transition through 'about:blank' will necessitate the re-loading of
that page.

Richard.

Jul 21 '06 #4
It would be more reliable, and no worse, to just pass the URL argument
into the initial call to - window.open -, as even if the URL argument
is the current URL of a page being displayed in that window the
transition through 'about:blank' will necessitate the re-loading of
that page.

Richard.
Have you actually tried running the code?

Vincent
Jul 21 '06 #5
Vincent van Beveren wrote:
>It would be more reliable, and no worse, to just pass the
URL argument into the initial call to - window.open -, as
even if the URL argument is the current URL of a page being
displayed in that window the transition through 'about:blank'
will necessitate the re-loading of that page.

Have you actually tried running the code?
Only to the extent of verifying that no content would ever get loaded
into a pop-up on current Opera browsers.

Richard.
Jul 23 '06 #6
>
Only to the extent of verifying that no content would ever get loaded
into a pop-up on current Opera browsers.
For IE and FireFox it works fine. I tried it now in and, as you said, it
doen't work (though it might with some tweaking). I understand the
theoretical problems with this code. Its rather 'hacked'. So, future
support will probably not garanteed. I was actually suprised myself that
it worked in IE and FF.

Vincent
Jul 24 '06 #7

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

6
by: Paolo Losi | last post by:
Hi all, I'm pretty new to the python language so please excuse me if this is FAQ... I'm very glad to be part of the list! :-) I'm looking into a way to implement a generic workflow framework...
1
by: Joe | last post by:
I was wondering if there are any recommended persistence frameworks for use in .NET that could be recommended. I am looking for the following requirements: Free/Open Source or very inexpensive....
7
by: Scott M. | last post by:
How can I disable the cross-site scripting check for one particular page of a site?
13
by: Mark Anthony Spiteri | last post by:
Hi, I am designing an ASP.NET application in which particular pages require global variables that need to be persisted during postbacks. What is the best practice to do this? Is it to use the...
5
by: DelphiAddict | last post by:
Hi. Has anyone looked into generic factoring for making database independant applications? (Framework 2.0) I have, but I'm in the starting fase. What I do know is that if you only write...
2
by: dkode | last post by:
Hello, I am laying out the architecture for a very large website that will scale to a very large degree. I have a couple of questions before I attempt to go and implement a Broker/Persistence...
5
by: Chris Spencer | last post by:
Before I get too carried away with something that's probably unnecessary, please allow me to throw around some ideas. I've been looking for a method of transparent, scalable, and human-readable...
0
myusernotyours
by: myusernotyours | last post by:
Hi all, Am trying to create a Java Desktop App that uses Java Persistence in Netbeans. The database is MS Access but I tried with Mysql and got the same error. When I run the app( Create the...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
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
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
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...
0
marktang
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,...
0
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...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.