DHTML - Disable parent window


Hi all,
    I have a sitiation where I need to make sure the user will not do anything on the parent window while a popup window
is running. There are a handful of fields in the parent window, so disabling one one one would be impossible. One way
to do this may be a show/hide with a div tag. But, being a beginner,  I'm just wondering whether there is a better way to do this .

thanks
~j
LVL 8
mxjijoAsked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

ZvonkoSystems architectCommented:
You can disable the complette form by disable the form object.
ZvonkoSystems architectCommented:
Here an example:

<html>
<head>
<title>Zvonko &#42;</title>
</head>
<body>
<form>
<input type="text" name="myField">
<input type="submit">
</form>
<a href="#" onClick="document.forms[0].disabled=true;return false">Disable</a>
<a href="#" onClick="document.forms[0].disabled=false;return false">Enable</a>
</body>
</html>

mxjijoAuthor Commented:

thanks for the quick response.
I have several fields outside the form.
Is it possible to disable the document itself ?
Determine the Perfect Price for Your IT Services

Do you wonder if your IT business is truly profitable or if you should raise your prices? Learn how to calculate your overhead burden with our free interactive tool and use it to determine the right price for your IT services. Download your free eBook now!

ZvonkoSystems architectCommented:
Fields outside the form???
What do you call fields what is NOT in a form?
Loop trough all forms on the document and disable all forms:

<html>
<head>
<title>Zvonko &#42;</title>
</head>
<body>
<form>
<input type="text" name="myField1">
<input type="submit">
</form>
<form>
<input type="text" name="myField2">
<input type="submit">
</form>
<form>
<input type="text" name="myField3">
<input type="submit">
</form>
<a href="#" onClick="f=document.forms;for(var i=0;i<f.length;i++)f[i].disabled=true;return false">Disable</a>
<a href="#" onClick="f=document.forms;for(var i=0;i<f.length;i++)f[i].disabled=false;return false">Enable</a>
</body>
</html>

mxjijoAuthor Commented:

I have a bunch of links outside the form
ZvonkoSystems architectCommented:
In your question you did NOT mention that.

<html>
<head>
<title>Zvonko &#42;</title>
</head>
<body>
<form>
<input type="text" name="myField1">
<input type="submit">
<a href="http://www.experts-exchange.com/">EE</>
</form>
<form>
<input type="text" name="myField2">
<input type="submit">
<a href="http://www.experts-exchange.com/">EE</>
</form>
<form>
<input type="text" name="myField3">
<input type="submit">
<a href="http://www.experts-exchange.com/">EE</>
</form>
<script>
var pop=window.open("","control","top=120,left=350,width=200,height=100");
with(pop.document){
  open();
  write('<html><head><title>Zvonko &#42;</title></head><body>');
  write('<center>');
  write('<a href="#" onClick="opener.document.body.onclick=function(){return false};');
  write('f=opener.document.forms;for(var i=0;i<f.length;i++)f[i].disabled=true;return false">Disable</a>');
  write('<br>');
  write('<a href="#" onClick="opener.document.body.onclick=null;');
  write('f=opener.document.forms;for(var i=0;i<f.length;i++)f[i].disabled=false;return false">Enable</a>');
  write('</center>');
  write('</body></html>');
  close();
}
pop.focus();
</script>
</body>
</html>

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
mxjijoAuthor Commented:

> What do you call fields what is NOT in a form?
>  In your question you did NOT mention that.


>> I have several fields outside the form.

     you don't count that ?? :)
ZvonkoSystems architectCommented:
Fields and Links are separate collections.

See you.
mxjijoAuthor Commented:


hmm.. I took another look at your code.. .
don't you think ALL the links in your are STILL inside a form ??
When I said I have fields (and links) outside form - I DID NOT mean they inside another form :)
I slightly modified your code to add a link OUTSIDE ALL froms - can you disable that ??

<html>
<head>
<title>Zvonko &#42;</title>
</head>
<body>

<a href="http://www.experts-exchange.com/">This is outside ALL forms</>

<form>
<input type="text" name="myField1">
<input type="submit">
<a href="http://www.experts-exchange.com/">EE</>
</form>


<form>
<input type="text" name="myField2">
<input type="submit">
<a href="http://www.experts-exchange.com/">EE</>
</form>

<form>
<input type="text" name="myField3">
<input type="submit">
<a href="http://www.experts-exchange.com/">EE</>
</form>

<script>
var pop=window.open("","control","top=120,left=350,width=200,height=100");
with(pop.document){
  open();
  write('<html><head><title>Zvonko &#42;</title></head><body>');
  write('<center>');
  write('<a href="#" onClick="opener.document.body.onclick=function(){return false};');
  write('f=opener.document.forms;for(var i=0;i<f.length;i++)f[i].disabled=true;return false">Disable</a>');
  write('<br>');
  write('<a href="#" onClick="opener.document.body.onclick=null;');
  write('f=opener.document.forms;for(var i=0;i<f.length;i++)f[i].disabled=false;return false">Enable</a>');
  write('</center>');
  write('</body></html>');
  close();
}
pop.focus();
</script>
</body>
</html>

ZvonkoSystems architectCommented:
LOL :-)

Collections are this:
document.forms
document.links

And both can be spread across the page.
So even when links are inside the form section does they NOT belong to the form elements.

mxjijoAuthor Commented:

thanks.. I'm not that famillier with html terminology/structure
ZvonkoSystems architectCommented:
Now I see your question!
The link is not clickable also when it does not look like disabled.
And it seams forms influence also elements inside the form section which do not belong to form collection to look like disabled. But withouth the clickk blocker would that disabled looking links stay active.
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
JavaScript

From novice to tech pro — start learning today.