0

How to avoid user to click outside popup window javascript ?

asked Dec 6, 2010 at 13:42
2
  • 4
    Wow. I love the details. Could you please rephrase? Commented Dec 6, 2010 at 13:44
  • @goreSplatter: I had to laugh :-D Commented Dec 6, 2010 at 13:46

4 Answers 4

2

If you want to avoid clicking of the content you can place a div with a fixed position over all the content. That prevents the user from clicking on everything that is not inside this div. I use this for some error reporting on a site.

Html:

<div id="error_wrapper">
 <div id="site_error">
 Error:
 </div>
</div>

Css:

div#error_wrapper {
 position: fixed;
 width: 100%;
 height: 100%;
 background-color: #000000;
 top: 0px;
 left: 0px;
 opacity: 0.7;
 filter: alpha(opacity=70);
}
div#site_error {
 position: fixed;
 top: 200px;
 width: 400px;
 left: 50%;
 margin-left: -200px;
}
answered Dec 6, 2010 at 13:51
Sign up to request clarification or add additional context in comments.

1 Comment

+1 for not going straight to a framework. Simple demo based on your HTML/CSS: jsfiddle.net/subhaze/2CrX5
1

I think you're asking about a modal dialog box. If so, have a look at the jQuery UI modal dialog.

It will open up a dialog box with custom HTML content, and the rest of the page will be grayed-out and un-clickable. Is that what you want?

answered Dec 6, 2010 at 13:44

Comments

0

If you meant to ask "can you prevent users from clicking outside a popup window", no, you can't. At least not with JavaScript. Just imagine how annoying that would be.

You need "deeper" access to the browser than what a bunch of JavaScript sitting on a webpage has in order to do this.

answered Dec 6, 2010 at 13:44

Comments

0

Just make a popup div follow the cursor with a mousemoveevent! I can see some flaws with the method, though.

answered Dec 6, 2010 at 14:15

Comments

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.