Click to See Complete Forum and Search --> : [RESOLVED] disable Iframes!!


DJ AkAJaY
11-29-2006, 09:51 AM
Hi all,

please i want to know if there is a way to disable an iframe.
Or if it is possible to disable all the controls on the iframe...

I explain :

i have a page (page A) who contains an iframe who call (page B)
i want to disable all the controls of the page B from the page A

If there is a solution i thank you by advance
:)

scragar
11-29-2006, 09:55 AM
I don't understand what your asking for...

could you explain it a little better?

IE: give a link, say what controls need to be disabled...

_Aerospace_Eng_
11-29-2006, 10:02 AM
Do you have control of page B or is it from a different site? You could set scrolling="no" on the iframe. That will remove scrollbars. Why exactly would you want to do this?

DJ AkAJaY
11-29-2006, 10:06 AM
okey thanks for your quick reply:

here is what i want to do :

my page contains an iframe

Page A :

<table width="100%" border="0" cellspacing="2" cellpadding="0">
<tr>
<td><iframe src="addphoto_new.php" frameborder="0" width="100%" height="400" name="framePics" id="framePics" scrolling="auto"></iframe></td>
</tr>
</table>

the "addphoto_new.php" contains a form like :

<form action="edit.php" id="frm_bien_r" name="frm_bien_r" method="POST" onSubmit="return validationForm(this);">
<table width="100%" border="0" cellspacing="0" cellpadding="0">
<tr>
<td align="right">
<input id="modifier" type="button" value="Modifier" onClick="btnModif();">
<input id="submiter" type="submit" value="Valider">
<input id="reseter" type="reset" value="Annuler">
</td>
</tr>
</table>
</form>


So my question is :
i am in the first page(page A) and i want to disable the iframe or the controls(button submit,button,reset)
is it possible?? i precise,i am in the (page A)

i hope you will understand me,i know that my english is not good :-(

_Aerospace_Eng_
11-29-2006, 10:10 AM
I'm a little confused as to why you want to disable it. If you don't want people using it then why even have it in the iframe in the first place?

DJ AkAJaY
11-29-2006, 10:12 AM
:) Aerospace_Eng_
i can control the page B ;)

why i want to do this, because i am obligate to put the page B in the iframe...
And the user can't access to controls until he pushes a button(on the page A) when he pushes the buttons,then he can access to controls of page B

DJ AkAJaY
11-29-2006, 10:15 AM
Because i have to reload only the page B sometimes :)

_Aerospace_Eng_
11-29-2006, 10:42 AM
Its not fool proof because javascript can be disabled. Add this in between the head tags of page B.
<script type="text/javascript">
function disableThem()
{
var inputs = document.getElementsByTagName('input');
for(var i = 0; i < inputs.length; i++)
{
inputs[i].disabled = true;
}
var selects = document.getElementsByTagName('select');
for(var j = 0; j < selects.length; j++)
{
selects[j].disabled = true;
}
var textareas = document.getElementsByTagName('textarea');
for(var k = 0; k < textareas.length; k++)
{
textareas[k].disabled = true;
}
}
window.onload = disableThem;
</script>
Then in page A put this in between the head tags.
<script type="text/javascript">
function enableThem()
{
var el = parent.frames['nameofiframe']; // this is the name of the iframe.
var inputs = el.document.getElementsByTagName('input');
for(var i = 0; i < inputs.length; i++)
{
inputs[i].disabled = false;
}
var selects = el.document.getElementsByTagName('select');
for(var j = 0; j < selects.length; j++)
{
selects[j].disabled = false;
}
var textareas = el.document.getElementsByTagName('textarea');
for(var k = 0; k < textareas.length; k++)
{
textareas[k].disabled = false;
}
}
</script>
Then just call the function using onclick or whatever
onclick="enableThem()"
Just be sure to match the iframe names in the javascript and html.

Good luck.

DJ AkAJaY
11-29-2006, 11:03 AM
Thanks a lot

it works ;)