473,569 Members | 2,617 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

iframe width cannot be controled ?

3 New Member
hi guys,

I am trying to make some iframes fit into a div with variable width. The iframe must have a margin, and using a padding in the parent div element is not an option.

Unfortunately, the width:auto for iframe gives a preset width, and does not behave like for the div elements.

As a result, the iframe always seem to resize its container.

See the testcases below :

This is how it behaves when a div contains a div with width:auto > that's the result I want to achieve with an iframe
<div style="width:10 0px;background-color:blue">Con tainer<div style="width:au to;margin:10px; background-color:white">co ntent</div></div>

This is how it behaves when a div contains an iframe with width:auto
<div style="width:10 0px;background-color:red">Cont ainer<iframe style="width:au to;margin:10px" src=""></iframe></div>

This is how it behaves when a div contains an iframe with width:100% (the container becomes too big)
<div style="width:10 0px;background-color:red">Cont ainer<iframe style="width:10 0%;margin:10px" src=""></iframe></div>


Any ideas ?
Thanks,

Yohann
Jul 2 '08 #1
2 4425
dlite922
1,584 Recognized Expert Top Contributor
may I ask why you need to use iFrame? maybe there's a different solution?

-Dan
Jul 6 '08 #2
hsriat
1,654 Recognized Expert Top Contributor
I tried, but could not get a CSS solution.

You may find this useful:
Expand|Select|Wrap|Line Numbers
  1. window.onload = function () {
  2.     var ifm = document.getElementsByTagName('iframe')[0];
  3.     ifm.style.width = ifm.parentNode.style.width;
  4. }
Jul 7 '08 #3

Sign in to post your reply or Sign up for a free account.

Similar topics

2
10138
by: Sticky | last post by:
I really need some help - i have already pulled out 1/2 my hear and the rest is following quickly..... I am designing a page containing an iFrame, the contents of which are selected dynamically by the user, and it needs to resize correspondingly - both height and width. the width isn't a problem; it is set from its parent object using...
3
8332
by: Greg | last post by:
Javascript Folks, I am relatively new to javascript and am working on a script where I want to utilizes a couple of iframes and format text in them. I have run into a problem with getting the following code to work in mozilla. It seems to work in ie. Eventually I will be replacing the H1 node with a table until I can get the H1 node to...
0
6066
by: Martin | last post by:
I understand that as of IE5.5 iframes respect the z-index style property. However I have noticed some odd behaviour when the iframe's src is set to an MHT web archive instead of an HTML file. For example: I have a DIV containing an IFRAME and an IMG, whose z-index is 1. I have a second, identical DIV except this one's z-index is set to 0. I...
1
6625
by: jaktharkhan | last post by:
Hi, I really really need help in trying to figure out how can I do a CloneNode on an Iframe where the cloned IFRAME clones with all its contents?. Basically what I am doing is dynamically building a table with Iframes inside it. The problem is I just want to build one Iframe because the contents of it can be very complex. After my Iframe is...
8
5357
by: hyejin | last post by:
I have a problem with dynamic iframe and document.close() on Firefox. Below two files create a dynamic iframe by JavaScript. These two samples do not have any problems on IE. But, on Firefox, the icon on the top corner keeps running with "loading" message on the bottom status bar even though the browser completed everything in the iFrame. ...
5
7696
by: brad | last post by:
I'll post my code below. My goal is to grab the selected text in an iFrame from javascript (really any way possible). When I highlight text in the iFrame and click the link outside of the iFrame, I receive the following error: Firefox FireBug Error uncaught exception: Permission denied to get property HTMLDocument.getSelection IE7 Error
7
3338
by: pb | last post by:
Hi all, I have some code that automatically generates a url depending on user selections. This url is then set as a hyperlink and the user clicks on the link that has the target as an iframe on the same page. What is the easier way to automatically fill the iframe with the required new web page without having to get the user to click on...
0
7765
by: tequilamala | last post by:
I have an Iframe in one of the pages i am developing... the iframe is suppose to scroll up and down and the links target the iframe. the problem is that the iframe scrolls side to side on internet explorer but not on firefox. I dont want it to scroll sideways. in index.htm the iframe is at the bottom of the code. index.htm <!DOCTYPE...
2
3778
by: olddocks | last post by:
i am planning on kind of editor by replacing the textarea with iframe so that i could edit the content with rich html. I am facing weird problem and i cannot set the value of iframe innerHTML with the value of textarea while loading. The idea is hide the textarea after moving the value to iframe rich text editor. what could be the problem....
0
7615
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language...
0
7924
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. ...
0
8130
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that...
0
7979
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the...
0
6284
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then...
1
5514
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes...
0
3653
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in...
0
3643
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2115
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.