Question

Locked

Javascript Window Fun

By sarchbold ·
Hello,

I am having a fun time trying to get something to work.

What I am trying to do is this.

I have Page A, Page B, and Page C

On Page A and Page B there are links that will open up a new browser window with an editable document.

I never want a user to be able to open more then one editable document window at a time.

What I require is if someone opens up a document on Page A and then brows from Page A to Page B while this document is still open and try to open up another document for editing it will stop them because it sees that a page is already open for editing.

As well if they are on page A and open a document and go to Page C then back again they will not be able to open up another editing document while the current one is still open.

And finally if they are on Page A, open up a document then try to open another one(this is currently working with the code below)

It?s a bit hard to explain but I hope the above gets the gist of it.

Currently my code looks like this:

-------------------
var NewWindow;

function OpenNewWindow(mypage, myoptions){
if (!NewWindow || NewWindow.closed ){
NewWindow=window.open("","frmNewDoc", myoptions);
try{
NewWindow.location.href; // throws exception if already loaded
//alert(NewWindow.location.href)
NewWindow.location = mypage;
}catch(e){

};
}
NewWindow.focus();
}


--------------------------
if(NewWindow && !NewWindow.closed) {
// already opened and not closed
alert("You may only edit one document at a time. Please close the existing window.")
}
else
{
OpenNewWindow("sub_ViewFrame.asp,'toolbar=no)
}


Any suggestions how I can accomplish my task?

Thanks

This conversation is currently closed to new comments.

2 total posts (Page 1 of 1)  
| Thread display: Collapse - | Expand +

All Answers

Share your knowledge
Back to Windows Forum
2 total posts (Page 1 of 1)  

Related Discussions

Related Forums