| Author |
Disable HTML frame using Javascript
|
Rakesh Keerthi
Ranch Hand
Joined: Jul 16, 2012
Posts: 103
|
|
Hi,
i have a html page with 3 frames(Index.html), and the preview is as in the screenshot. Here in Welcome.html i have a button named block. when i click this button i want left.html to be disabled(the frame in left side), i'm able to do it., but the form elements(the links) are still enabled. anyone please help me on how to disable even them. the code I've written is as below.
Index.html
HTML Code:
Left.html
HTML Code:
Welcome.html
HTML Code:
Thanks
|
 |
Eric Pascarello
author
Rancher
Joined: Nov 08, 2001
Posts: 15362
|
|
You need to loop through the form elements and disable them. Just doing it on the form will not do it.
Eric>
|
 |
Rakesh Keerthi
Ranch Hand
Joined: Jul 16, 2012
Posts: 103
|
|
Hi Eric,
thanks for the answer. i've updated the code as below. but, still it is not blocking the links.
Could you please let me know where am i going wrong.
Thanks
|
 |
Eric Pascarello
author
Rancher
Joined: Nov 08, 2001
Posts: 15362
|
|
|
Links are not part of forms.
|
 |
Rakesh Keerthi
Ranch Hand
Joined: Jul 16, 2012
Posts: 103
|
|
Eric,
could you please tell me how do i disable them. please.
Thanks
|
 |
Eric Pascarello
author
Rancher
Joined: Nov 08, 2001
Posts: 15362
|
|
You should have to loop through the document.links and add an onclick handler that returns false since links do not support the disabled attribute.
|
 |
Sunderam Goplalan
Ranch Hand
Joined: Oct 10, 2011
Posts: 63
|
|
function disabledFrame()
{
var links = parent.Left.document.links;
for (var i=0; i<links.length; i++)
{
links[i].onclick = function() { return false }
}
}
should disable the links.
|
SCJP 5.0 , SCEA Java EE 5
|
 |
Eric Pascarello
author
Rancher
Joined: Nov 08, 2001
Posts: 15362
|
|
Only problem with that code is if there is a onclick handler on it, you wiped it out.
|
 |
Rakesh Keerthi
Ranch Hand
Joined: Jul 16, 2012
Posts: 103
|
|
Thanks for the help guys. they are really helpful. i've solved it with the below code.
thanks again guys
|
 |
Eric Pascarello
author
Rancher
Joined: Nov 08, 2001
Posts: 15362
|
|
Why hard code it? What if another link or form field is added? You will have to maintain that list.
Eric
|
 |
 |
|
|
subject: Disable HTML frame using Javascript
|
|
|