mxjijo
asked on
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
You can disable the complette form by disable the form object.
Here an example:
<html>
<head>
<title>Zvonko *</title>
</head>
<body>
<form>
<input type="text" name="myField">
<input type="submit">
</form>
<a href="#" onClick="document.forms[0] .disabled= true;retur n false">Disable</a>
<a href="#" onClick="document.forms[0] .disabled= false;retu rn false">Enable</a>
</body>
</html>
<html>
<head>
<title>Zvonko *</title>
</head>
<body>
<form>
<input type="text" name="myField">
<input type="submit">
</form>
<a href="#" onClick="document.forms[0]
<a href="#" onClick="document.forms[0]
</body>
</html>
ASKER
thanks for the quick response.
I have several fields outside the form.
Is it possible to disable the document itself ?
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 *</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].di sabled=tru e;return false">Disable</a>
<a href="#" onClick="f=document.forms; for(var i=0;i<f.length;i++)f[i].di sabled=fal se;return false">Enable</a>
</body>
</html>
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 *</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;
<a href="#" onClick="f=document.forms;
</body>
</html>
ASKER
I have a bunch of links outside the form
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
> 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 ?? :)
Fields and Links are separate collections.
See you.
See you.
ASKER
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 *</title>
</head>
<body>
<a href="https://www.experts-exchange.com/">This is outside ALL forms</>
<form>
<input type="text" name="myField1">
<input type="submit">
<a href="https://www.experts-exchange.com/">EE</>
</form>
<form>
<input type="text" name="myField2">
<input type="submit">
<a href="https://www.experts-exchange.com/">EE</>
</form>
<form>
<input type="text" name="myField3">
<input type="submit">
<a href="https://www.experts-exchange.com/">EE</>
</form>
<script>
var pop=window.open("","contro
with(pop.document){
open();
write('<html><head><title>
write('<center>');
write('<a href="#" onClick="opener.document.b
write('f=opener.document.f
write('<br>');
write('<a href="#" onClick="opener.document.b
write('f=opener.document.f
write('</center>');
write('</body></html>');
close();
}
pop.focus();
</script>
</body>
</html>
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.
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.
ASKER
thanks.. I'm not that famillier with html terminology/structure
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.
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.