Jian0203
05-17-2012, 02:13 AM
Here is my scenario, i have a html that allows the user to retrieve .pdf file from the server.
If the users are trying to open the html again, mean the user open a new tab/window to the same html url, the window will prompt the user that the html is already opened.
The user will need to close the old html tab/window first before open a new one.
Is it possible to stop the users to open the new same html file before he/she closes the old one ? Is there any link that teach the tutorial about this ?
I am wondering do i need to use cookies in the browser to store the url in order to compare to the new tab/window url ?
Thanks for helping. I appreciate this a lot. :)
felgall
05-17-2012, 03:00 AM
If you do manage to do something using a cookie then it would still be able to be bypassed simply by using a different browser.
Jian0203
05-17-2012, 03:07 AM
If you do manage to do something using a cookie then it would still be able to be bypassed simply by using a different browser.
Er... Do you mind to explain a little about this ? I don't really understand ~ Sorry for troubling you ~~ :(
Old Pedant
05-17-2012, 03:14 AM
There's an easy fix for this that should do what you want, or at least give the same effect.
<a href="someFile.pdf" target="MYPDF"> click to open </a>
Now, even if the user DOES click again, the PDF file will open in the *SAME* window (or tab)! That is, by specifying the target, you are telling the browser to re-use that window, NOT open another one.
If you are opening the PDF window via JavaScript, again just give the window name:
window.open("someFile.pdf","MYPDF","width=900,height=700");
Jian0203
05-17-2012, 03:34 AM
There's an easy fix for this that should do what you want, or at least give the same effect.
<a href="someFile.pdf" target="MYPDF"> click to open </a>
Now, even if the user DOES click again, the PDF file will open in the *SAME* window (or tab)! That is, by specifying the target, you are telling the browser to re-use that window, NOT open another one.
If you are opening the PDF window via JavaScript, again just give the window name:
window.open("someFile.pdf","MYPDF","width=900,height=700");
but I have my concern. Because the pdf opened CAN only be closed after the machine has finished a process, but some users just don't follow the instructions.
they will still open another tab/windows to run the html to view another pdf that might cause confusion to other users whether which one is the correct reference pdf.
So, I want to restrict the users to open the html in new tab/window before he/she closes the old html. :(
Is it possible to do so ? Thanks for helping :)
Old Pedant
05-17-2012, 11:16 PM
Did you try my answer?
Try it first, then see if it really has problems.
I don't see how cookies could help you. How will a cookie know whether or not the prior tab/window has been closed???