File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes HTML, CSS and JavaScript and the fly likes Disable HTML frame using Javascript Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Engineering » HTML, CSS and JavaScript
Bookmark "Disable HTML frame using Javascript" Watch "Disable HTML frame using Javascript" New topic
Author

Disable HTML frame using Javascript

Rakesh Keerthi
Ranch Hand

Joined: Jul 16, 2012
Posts: 144
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: 15376
    
    6
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: 144
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: 15376
    
    6
Links are not part of forms.
Rakesh Keerthi
Ranch Hand

Joined: Jul 16, 2012
Posts: 144
Eric,
could you please tell me how do i disable them. please.

Thanks
Eric Pascarello
author
Rancher

Joined: Nov 08, 2001
Posts: 15376
    
    6
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: 75
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, TOGAF Certified
Eric Pascarello
author
Rancher

Joined: Nov 08, 2001
Posts: 15376
    
    6
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: 144
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: 15376
    
    6
Why hard code it? What if another link or form field is added? You will have to maintain that list.

Eric
 
wood burning stoves
 
subject: Disable HTML frame using Javascript