views:

131

answers:

2

How do i change the height of an iFrame, on hover, using jQuery?

I've tried this:

<script type="text/javascript"> 
  $(document).ready(function(){
    $(".googlemaps").hover( function(){
      $('#googlemaps').height(300);
    });
  });
</script>

My iframe is:

<div class="googlemaps">
 <xsl:variable name="location"><xsl:value-of select="DocumentEdition/Fields/Field[@Name = 'Location']" /></xsl:variable>
 <iframe id="googlemaps" width="489" height="215" frameborder="0" scrolling="no" marginheight="0" marginwidth="0" src="http://maps.google.dk/maps?f=q&amp;amp;source=s_q&amp;amp;hl=da&amp;amp;geocode=&amp;amp;q={$location}&amp;amp;output=embed"&gt;&amp;#160;&lt;/iframe&gt;&lt;br /><small><a href="http://maps.google.dk/maps?f=q&amp;amp;source=embed&amp;amp;hl=da&amp;amp;geocode=&amp;amp;q=skive&amp;amp;sll=55.869147,11.228027&amp;amp;sspn=7.860459,28.54248&amp;amp;ie=UTF8&amp;amp;hq=&amp;amp;hnear=Skive&amp;amp;z=13&amp;amp;ll=56.565498,9.021939" style="color:#0000FF;text-align:left">Vis stort kort</a></small>
</div>
A: 

Your code seems to be fine but try this too:

$('#googlemaps').attr('height', 300 + 'px');
Sarfraz
A: 

Your code is fine. It seems that Google is resizing the iframe back to its original size. Remove the URLs and you'll see.

Álvaro G. Vicario