Click here to Skip to main content
15,888,968 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
How to prevent in asp.net from opening another tab/Window in Web Browser? How to restrict to remain in the same tab of web browser?
Urgent please Reply.
Posted
Comments
Sri Nivas (Vasu) 19-Jan-16 8:55am    
What exactly you want to do here? Want to prevent opening on new tab when user clicks on any link ?

You cannot control the user's computer from code running on the server, or from code running in a web page.

What you are trying to do is impossible.

And no, it's not urgent.
 
Share this answer
 
Do you want to open web page on the same page instead of new tab if you click on any link? if yes then you need to set the target property of the hyper link go through the below links you will understand what you need to do.

HTML a target Attribute[^]

html - target="_blank" vs. target="_new" - Stack Overflow[^]

If you are not looking for this please elaborate your question so that any one can give answer to your question.

Hope this will helpful.
 
Share this answer
 
Comments
jaywant1503 19-Jan-16 9:19am    
no i want to restrict the user to remain on the same tab of web browser.If suppose student giving exam online.So he can not switch to another tab or window of web browser to see the content from internet.so how could it be possible?
Richard Deeming 19-Jan-16 10:22am    
Even if that was possible, what's to stop the user from opening a new instance of the browser?

Or opening a different browser? (I have five installed on my computer.)

Or using a different computer? Or their phone?

As I said, what you are trying to achieve is impossible.
Sri Nivas (Vasu) 19-Jan-16 9:34am    
You can do this check below.
http://stackoverflow.com/questions/821011/how-do-you-prevent-javascript-page-from-navigating-away
But I think this won't work in all browsers.
Good luck :)
If it was possible for a website to stop a user opening other tabs, don't you think every annoying click-bait and advert-laiden site would do exactly this? Or all those fake "download Flash" sites etc etc? If you're never seen a site do something then chances are it's not possible.

If I knew a way to stop people cheating on tests I wouldn't be telling you how to do it, I'd be too busy spending my billion pounds.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900