-3

Any Solution ?

I have looked into many solution but not worked.

for example I want to load yahoo.com, cnet.com and etc ... In this case I need to show them in iFrame but the same size as it can be seen in separate window or tab in the browsers.

Finally I found the solution , hey guys share this one.

<div id="frmLayout" style="position: absolute; top: 33px; left: 0; bottom: 0; right: 0;">
<iframe id="frm" style="position: absolute; width: 100%; height: 100%; overflow: auto; border: 0" src="http://news.yahoo.com/storms-kill-4-damage-branson-theater-district-    152532082.html"></iframe>
</div>    
Mojtaba
  • 9
  • 2
  • 7
  • I forget to notice that my iFrame loads another website like google,yahoo and so on. – Mojtaba Feb 29 '12 at 09:19
  • 2
    Hello and welcome to Stackoverflow. Please have a look at the [faq](http://stackoverflow.com/faq) and update your question with a little more information. – stealthyninja Feb 29 '12 at 09:21
  • corresponding to your title have you tried height="800" or do you want to dynamically change the height of your iframe ? – mas-designs Feb 29 '12 at 09:23
  • I have posted an answer. not sure if this works but gimme a response if it did – mas-designs Feb 29 '12 at 09:37
  • @Mojtaba Please rephrase your question. If you leave out the important parts from your question, no wonder you get useless solutions. – kapa Feb 29 '12 at 09:38
  • possible duplicate of http://stackoverflow.com/questions/153152/resizing-an-iframe-based-on-content – kapa Feb 29 '12 at 10:01
  • I will check it out , maybe it work. – Mojtaba Feb 29 '12 at 10:08
  • @Mojtaba It will surely work if it has more than 200 upvotes :). – kapa Feb 29 '12 at 10:39
  • @bazmegakapa I have found the solution ! Check the above. – Mojtaba Feb 29 '12 at 17:15
  • Happy you found the solution. Seems like you still did not manage to explain us what your problem is and everybody misunderstood it :). – kapa Feb 29 '12 at 20:00
  • @bazmegakapa i stated my problem above. really you misunderstood ? – Mojtaba Mar 01 '12 at 09:44
  • @Mojtaba I thought you have to size your iframe to the size of the page it holds. Your solution implies you are sizing it to the size of the browser window. – kapa Mar 01 '12 at 09:52

3 Answers3

0

Give your iframe element an id or class attribute so you can access it then you should be able to change the height with jQuery by doing something like:

$('#my_iframe').css('height', 800);

// or 

$('#my_iframe').height(800);

Hope this helps?

dialog
  • 11
  • 2
0

Check this webpage with this script:

This is a script which may help you. But I would suggest you go in another direction. Using Iframes is not always a good practice. But if there is no other way, go for it ;-)

kapa
  • 77,694
  • 21
  • 158
  • 175
mas-designs
  • 7,498
  • 1
  • 31
  • 56
  • http://stackoverflow.com/questions/362730/are-iframes-considered-bad-practice http://stackoverflow.com/questions/96748/are-iframes-a-terrible-idea read through this ! – mas-designs Feb 29 '12 at 09:40
  • @EvilP I did. Noone says using `iframe`s is a bad practice. For loading third-party sites into your HTML document, they are still the best solution. For a lot of other things, they are a bad solution. If you say `iframes are bad practice` you are simply wrong. It depends what you use them for ([and the OP uses them the right way](http://stackoverflow.com/questions/9495661/how-to-load-a-website-into-div-tag-in-jquery)). – kapa Feb 29 '12 at 09:44
  • @bazmegakapa do you have any idea to how set dynamically the height for the iFrame ? – Mojtaba Feb 29 '12 at 09:47
0
<div id="frmLayout" style="position: absolute; top: 33px; left: 0; bottom: 0; right: 0;">
<iframe id="frm" style="position: absolute; width: 100%; height: 100%; overflow: auto;    border: 0" src="http://news.yahoo.com/storms-kill-4-damage-branson-theater-district-    152532082.html"></iframe>    
  </div>    

you can change the position with jquery as best as possible.

Mojtaba
  • 9
  • 2
  • 7