onUnload to Save Data to Database

JavaScript and client side scripting.

Moderator: General Moderators

User avatar
scorphus
Forum Regular
Posts: 589
Joined: Fri May 09, 2003 11:53 pm
Location: Belo Horizonte, Brazil
Contact:

Post by scorphus »

You got it right, Pyrite. I'll look if there is a way to catch on-the-fly the URL the frame is being redirected to... Just curious, why that is not an option?
User avatar
Pyrite
Forum Regular
Posts: 769
Joined: Tue Sep 23, 2003 11:07 pm
Location: The Republic of Texas
Contact:

Post by Pyrite »

Well, I am not the one creating the links in the other frame, so I don't know what they are ahead of time.
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

example only

Code: Select all

<script>
var linkage = document.frames&#1111;1].links;
for(var x = 0, j = linkage.length; x < j; x++)
&#123;
if(linkage&#1111;x].onload != null)
&#123;
// it has an onload attached.. needs special processing
&#125;
else
&#123;
// it didn't have an onload
linkage&#1111;x].onload = ""; // whatever code you need here..
&#125;
&#125;</script>
User avatar
scorphus
Forum Regular
Posts: 589
Joined: Fri May 09, 2003 11:53 pm
Location: Belo Horizonte, Brazil
Contact:

Post by scorphus »

Nice tips, feyd.

Fellas, with feyd's tips and dozen changes I came into this: http://scorphus.no-ip.com/lab/frames2/ . I think it's a bit complicated, but it can become an option. Well, I hope, it took me almost 3/2 hours ;)

Cheers,
Sco.
User avatar
scorphus
Forum Regular
Posts: 589
Joined: Fri May 09, 2003 11:53 pm
Location: Belo Horizonte, Brazil
Contact:

Post by scorphus »

I made some modifications to not loose changes or have duplicated data when user hits 'Save' button and then goes to another page. Frames3: http://scorphus.no-ip.com/lab/frames3/

Scorphus.
cgroup
Forum Newbie
Posts: 13
Joined: Tue Jun 03, 2003 11:51 pm
Location: PA

Post by cgroup »

I had attempted to do something similar here:
http://www.fopo.net/south/scripts/timecounter/

It is a counter that tracks how long the person has been on your website and then submits it into an iframe onUnload. The only problem I had was that the page would close before the form finished submitting and the data was saved, so I used an alert to stall long enough for the page to finish loading in the iframe.
Guilherme Blanco
Forum Newbie
Posts: 12
Joined: Wed Jun 02, 2004 4:58 pm
Location: São Carlos - SP/Brazil
Contact:

Post by Guilherme Blanco »

You simply have to use JavaScript RPC of Paul Whitrow...

Call a javascript function that calls the PHP code to execute.

Look at the link: http://www.alphafilter.com/go.foo/article/?aid=10/

Regards,
Post Reply