html


Make image size responsive inside iframe


I have an iframe on a page that will display an image file I am hosting.
I can make the iframe responive so that it get's larger or smaller depending on window size but am looking to have the actual image in the iframe scale to fit the iframe as opposed to having the scroll bars appear when the iframe gets smaller than the image. Is there a way to do this?
Below is the code I am working with where http://example.net/picture.jpg is the hosted image.
<!DOCTYPE html>
<html>
<head>
<script type="text/javascript">
var frm = ['gallery', 'info'];
var hrf = ['http://example.com/', 'http://example.net/picture.jpg'];
function setSource() {
for(i=0, l=frm.length; i<l; i++) {
document.querySelector('iframe[name="'+frm[i]+'"]').src = hrf[i];
}
}
</script>
</head>
<body>
<iframe src="" name="gallery"></iframe>
<iframe src="" name="info"></iframe>
<span onclick="javascript: setSource();">Click me</span>
</body>
</html>

Related Links

CRLF Displayed as Newline plus Space in <pre> tag
Input type file has delay to open when use accept .xml
What is the difference between these two methods of css? [duplicate]
<div> padding auto increasing when using table-cell
How do I align these pictures vertically?
html align doesn't work when loop
Iphone square radio button issue
I need to centered element in a form inline
How should i change $.ajax part of code to work it out?
Copying columns of values from Excel worksheet to an HTML table in a website
rvest cannot find node with xpath
How to call HTML button without ID or Name using VBA?
How do we ignore <body scroll=“no”> in MS webbrowser control
Using <embed> to embed an HTML document causes large gap
How can I make a sprite element look selected like regular text?
Regex that makes sure a match starts with a string

Categories

HOME
wcf
salt
identityserver3
autoprefixer
time-series
innodb
titanium
doctrine-query
chm
couchbase
java-9
aes
indexeddb
yarnpkg
code-first
data-cleaning
extension-methods
sliders
maven-war-plugin
concat
watson-virtual-agent
preact
shellcode
organization
pangocairo
pebble-sdk
android-shortcut
ecm
http-status-code-403
angular-ui-tabset
google-inbox
exist-db
sccm
torquebox
android-bootstrap-widgets
vocabulary
latent-semantic-analysis
git-commit
matter.js
pkg-config
hive-udf
gwt-2.7
usb-modeswitch
droidparts
python-3.3
icacls
numa
logistics
gift
htmlelements
wscript
jquery-templates
multiple-databases
transpiler
fat16
self-signed
factual
addclass
math-mode
server-push
sap-smp
postgresql-8.2
xubuntu
retention
sitefinity-5
array-multisort
odf
system.printing
particle-filter
branding
xcode4.3
django-grappelli
ibatis.net
pdf-to-html
azure-storage-emulator
mdbg
facescontext
seam-carving
django-comments
webrick
firefox3.6
prefix-tree
sandy3d
innovation
mfc-networking

Resources

Mobile Apps Dev
Database Users
javascript
java
csharp
php
android
MS Developer
developer works
python
ios
c
html
jquery
RDBMS discuss
Cloud Virtualization
Database Dev&Adm
javascript
java
csharp
php
python
android
jquery
ruby
ios
html
Mobile App
Mobile App
Mobile App