How to edit HTML when an link is clicked

JavaScript and client side scripting.

Moderator: General Moderators

Post Reply
User avatar
vigge89
Forum Regular
Posts: 875
Joined: Wed Jul 30, 2003 3:29 am
Location: Sweden

How to edit HTML when an link is clicked

Post 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?
Unipus
Forum Contributor
Posts: 409
Joined: Tue Aug 26, 2003 2:06 pm
Location: Los Angeles, CA

Post 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.
User avatar
vigge89
Forum Regular
Posts: 875
Joined: Wed Jul 30, 2003 3:29 am
Location: Sweden

Post by vigge89 »

what do you mean by
"assign the iframe an ID as well as a name. "
ID?
User avatar
code_monkey
Forum Newbie
Posts: 16
Joined: Tue Jul 08, 2003 6:13 am
Location: UK
Contact:

Post by code_monkey »

You want somthing like name and id eg.

Code: Select all

<iframe name="iframe1" id="iframe1">
in your iframe tag.
User avatar
vigge89
Forum Regular
Posts: 875
Joined: Wed Jul 30, 2003 3:29 am
Location: Sweden

Post by vigge89 »

ok, ill try it out now, thanks!
Post Reply