[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 414
  • Last Modified:

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
0
mxjijo
Asked:
mxjijo
  • 7
  • 5
1 Solution
 
ZvonkoSystems architectCommented:
You can disable the complette form by disable the form object.
0
 
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>

0
 
mxjijoAuthor Commented:

thanks for the quick response.
I have several fields outside the form.
Is it possible to disable the document itself ?
0
VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

 
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>

0
 
mxjijoAuthor Commented:

I have a bunch of links outside the form
0
 
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>

0
 
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 ?? :)
0
 
ZvonkoSystems architectCommented:
Fields and Links are separate collections.

See you.
0
 
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>

0
 
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.

0
 
mxjijoAuthor Commented:

thanks.. I'm not that famillier with html terminology/structure
0
 
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.
0

Featured Post

Important Lessons on Recovering from Petya

In their most recent webinar, Skyport Systems explores ways to isolate and protect critical databases to keep the core of your company safe from harm.

  • 7
  • 5
Tackle projects and never again get stuck behind a technical roadblock.
Join Now