Page 1 of 1

How to edit HTML when an link is clicked

Posted: Thu Jan 22, 2004 11:13 am
by vigge89
When the user clicks a link, i would like the browser to edit an Iframe's height. The iframe's name is 'iframe1'. How could i do this, in either DHTML or Javascript?

Posted: Thu Jan 22, 2004 1:52 pm
by Unipus
first of all, assign the iframe an ID as well as a name.

<a href="whatever" onclick="resize('iframe1','200')">blag</a>

and then the function:

Code: Select all

function resize(objectID, newHeight) &#123;
     var objStyle = document.getElementById(objectID).style;
     objStyle.height = newHeight + "px";
&#125;
untested, but it should work (this would change iframe1's height to 200px). Note that you may have to explicitly define iframe1's height beforehand or it may not work.

Posted: Fri Jan 23, 2004 10:27 am
by vigge89
what do you mean by
"assign the iframe an ID as well as a name. "
ID?

Posted: Fri Jan 23, 2004 11:41 am
by code_monkey
You want somthing like name and id eg.

Code: Select all

<iframe name="iframe1" id="iframe1">
in your iframe tag.

Posted: Fri Jan 23, 2004 1:09 pm
by vigge89
ok, ill try it out now, thanks!