• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Ron McLeod
  • Paul Clapham
  • Bear Bibeault
  • Junilu Lacar
Sheriffs:
  • Jeanne Boyarsky
  • Tim Cooke
  • Henry Wong
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • salvin francis
  • Frits Walraven
Bartenders:
  • Scott Selikoff
  • Piet Souris
  • Carey Brown

Prevent opening page in new window

 
Ranch Hand
Posts: 294
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi all
I have this parent page containing iframe,
When user click link in the iframe, the iframe content updates - everything is ok.
the problem happen when user right click a link in the iframe and select "open in new window" then new window opens without the parent content (just the iframe content)

I would like to prevent this situation by changing the window URL to the main application page,
How do I identify in the new window that I am not inside the parent?
How to handle ‘window.open()’ calls that open popup content without the parent?

Thank you
 
Marshal
Posts: 67446
173
Mac Mac OS X IntelliJ IDE jQuery Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Aside from disbaling the context menu -- which would not be a good thing to do (see InterfaceDesignersRule1) -- the only thing I can think of is to detect (with JavaScript) that the newly opened "child" page is not within its parent and to redirect to the parent. Which child page needs to be displayed within the parent can be carried as a request param or stored in the session.

That could get really messy, and you'd need to do this on each "child" page. Personally, I'd consider just letting it be unless it poses security issues. If the outcome is undesirable, people learn not to do it soon enough.
 
Sharon whipple
Ranch Hand
Posts: 294
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
>>>Personally, I'd consider just letting it be unless it poses security issues
Thank you Bear, if I will have no choice I will do that.

I think I found client side solution
When User login to the system the main window is open (considered as top in JavaScript) it contains the IFrame (different web application)
In JavaScript i will test if (top == window.parent) - if not redirect to the main page
Top is the main window (start page), window.parent should be the containing app

The only problem are popup windows within the IFrame in normal operation..
I am still thinking how to solve it..
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
    Bookmark Topic Watch Topic
  • New Topic