This week's book giveaways are in the Refactoring and Agile forums.
We're giving away four copies each of Re-engineering Legacy Software and Docker in Action and have the authors on-line!
See this thread and this one for details.
Win a copy of Re-engineering Legacy Software this week in the Refactoring forum
or Docker in Action in the Cloud/Virtualization forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Disable HTML frame using Javascript

 
Rakesh Keerthi
Ranch Hand
Posts: 152
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 15385
6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 152
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 15385
6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Links are not part of forms.
 
Rakesh Keerthi
Ranch Hand
Posts: 152
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Eric,
could you please tell me how do i disable them. please.

Thanks
 
Eric Pascarello
author
Rancher
Posts: 15385
6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 86
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
Eric Pascarello
author
Rancher
Posts: 15385
6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Only problem with that code is if there is a onclick handler on it, you wiped it out.

 
Rakesh Keerthi
Ranch Hand
Posts: 152
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks for the help guys. they are really helpful. i've solved it with the below code.





thanks again guys
 
Eric Pascarello
author
Rancher
Posts: 15385
6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Why hard code it? What if another link or form field is added? You will have to maintain that list.

Eric
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic