Created
September 18, 2019 10:49
-
-
Save fatihgvn/a5b561024e0eaf5853968b8270d26443 to your computer and use it in GitHub Desktop.
iframe auto resize from width
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$(function() { | |
// auto size iframe | |
$('iframe[data-size]').each(function () { | |
var frame = $(this); | |
var size = frame.data('size').split('x'); | |
var rate = size[0]/size[1]; | |
frame.width(size[0]); | |
frame.height(frame.width()/rate); | |
this.contentWindow.addEventListener('resize', function(){ | |
frame.height(frame.width()/rate); | |
}); | |
}); | |
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<iframe src="http://adOrSiteView.com/example" scrolling="no" data-size="728x90"></iframe> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
iframe{ | |
border: none; | |
overflow: hidden; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment