Forum Moderators: open

Message Too Old, No Replies

Preventing from "open in new window"

using a right click mouse menu

         

Savage2000

2:58 pm on Mar 17, 2011 (gmt 0)

10+ Year Member



Hi!

We have a site with stateless logic, and we have all our URLs organized in such way:

http://www.example.com/crm/search.html?sessionid=12345.

But when one opens new window from our site URL - we need to assign a new sessionid to it.
That's why we've created a special button for creating a new windows with new sessionid. But, unfortunately, user still can open link in new page by "open in new window" menu.

Question: Is there any good way to prevent user from opening new windows by himself, allowing doing it only using our procedure?

I have some ideas, but there are not so great:
1. Create JavaScript to add "onclick" event on every <a> tag and do some job in handler. When user select "open in new window" - "onclick" is not fired.
2. Disable right mouse button use on a pages:

document.oncontextmenu = test;
function test() {
return false
}

[edited by: Fotiman at 3:43 pm (utc) on Mar 17, 2011]
[edit reason] Examplified URL [/edit]

rocknbil

4:45 pm on Mar 17, 2011 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Well, this goes against one of the foundations of building web sites, never dictate to the users how the web should work. It means there is something in your process that needs to be modified to accommodate your users, not the other way around.

Add to that any disabling of the controls we all know and love is annoying and will put off a lot of your visitors. Disabling any mouse actions, I think, is one of the contributing factors to disabling Javascript.

On that thought, why can't you use cookies? User lands on your page - any page - you set a cookie, they open in a new window, if cookie use that value, if not, use the URL. Shouldn't be too difficult to manage.