Accessing new URL in onbeforeunload - or similar effect by othermeans

P

Pete Verdon

Hi,

I'm working on a substantial AJAX-type application. The latest feature
I've added is the ability to append a query string to the end of the
normal URL, which will cause the application to open a new tab (within
itself, not a browser tab) according to the contents of this string,
alongside the normal tabs it provides. This all works as expected.

What I would now like to do is provide the ability to open a second such
tab alongside the first, without leaving the application (it has an
unfortunately long startup time due to a slow server I have no control
over). My initial plan was to trap onbeforeunload (which I already do to
provide a "do you want to quit?" dialog), see what the new URL is, and
if it's the URL of the application but with a different query string,
cancel the unload and create the new tab instead.

Of course, this doesn't work, and there are a couple of perfectly good
reasons why it never could have done. But does anyone have a suggestion
for a different approach?

Thanks,

Pete
 
P

Pete Verdon

If there was a way to catch the unload and prevent it happening then popup
adverts everywhere would use it to prevent you closing the popups.

Yup, that's one of the reasons I thought of :)
A different approach would be to use the onload event for your page to go
through all <a> tags in the page and add an onclick handler which does what
you want.

I don't think that would do what I need. I want people to be able to
paste in URLs (or load bookmarks, or whatever) in the same window, to
kick the client into a new state. People here really want to be able to
IM / email each other links to particular entities/states within the
application. What I've done so far will allow them to load one such URL,
but if they have a second they would have to load another copy of the
app, which is a) slow and b) bypasses the existing interface which
allows them to look at several things side-by-side.

Of course, this is even more of a perversion of the standard browser
model than normal AJAX is :)

Perhaps I can work around it by adding a text field to paste additional
URLs into, but it's not ideal.

Pete
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
474,444
Messages
2,571,709
Members
48,796
Latest member
Greg L.
Top