Jump to content
  • 0

pomoc Dynamický iframe


Quiter

Dotaz

Čaute.

 

Potreboval by som pomoc s dynamickým iframe.

Potrebujem aby sa jeho veľkosť upravovala podla obsahu.

 

Na nete som si našiel script, ktorý mi v škole funguje ale doma nie, neviete niekto prečo a čo s tým ?

<iframe id="myFrame" src=""></iframe>

 
<script type="text/javascript">
var f = document.getElementById("myFrame");
f.onload = function() {
  this.height = this.contentWindow.document.body.offsetHeight;
}
</script>
Link to comment
Share on other sites

18 odpovědí na tuto otázku

Recommended Posts

  • 0

no nebude tam nič vačšie, proste width chcem mať stále rovnaký... len height potrebujem dynamický

 

ano cestu nastavujem...

 

mňa by skôr zaujímalo, prečo mi to v škole fungovalo a doma už nie...

Link to comment
Share on other sites

  • 0

<script type="text/javascript">

var f = document.getElementById("myFrame");

f.height = f.contentWindow.document.body.offsetHeight;

</script>

 

takto si to myslel?

Edited by MasterMatoSK
Link to comment
Share on other sites

  • 0

<script type="text/javascript">

var f = document.getElementById("myFrame");

f.height = f.contentWindow.document.body.offsetHeight;

</script>

 

takto si to myslel?

Ani toto mi nefunguje... ten iframe je stále rovnaký...

Link to comment
Share on other sites

  • 0

<script type="text/javascript">

var f = document.getElementById("myFrame");

f.style.height = f.contentWindow.document.body.offsetHeight + 'px';

</script>

 

toto musí fungovať, lebo ak nie, už neviem

Link to comment
Share on other sites

  • 0
<html>
	<head>
		<title>Quiter</title>
		<link rel="stylesheet" type="text/css" href="style.css"/>
	</head>
	<body>
		<div class="top"></div>
		<div class="cont">
			<div id="header">Quiter</div>
		</div>
		<div class="bottom"></div>

		<iframe id="myFrame" src="page/news.html"></iframe>
		<script type="text/javascript">
			var f = document.getElementById("myFrame");
			f.onload = function() 
			{
  				this.height = this.contentWindow.document.body.offsetHeight;
			}
		</script>
	</body>
</html>

Takto mám celé HTML a nefunguje to...

Link to comment
Share on other sites

  • 0

<script type="text/javascript">

var f = document.getElementById("myFrame");

f.style.height = f.contentWindow.document.body.offsetHeight + 'px';

</script>

 

no ale toto použi :d

Link to comment
Share on other sites

  • 0

tak sa na to vyserieme a použijeme jquery

 

$("iframe").load(function() {

f.style.height = f.contentWindow.document.body.offsetHeight + 'px';

});

 

tu netreba žiadny class alebo do id dávať, je to globálne, no proste pre iframe

 

ešte jedno, iframe sa neukončuje </iframe> ale hneď ako to spúštaš: <iframe src="page/news.php" />

Link to comment
Share on other sites

  • 0

Škoda.

Ako použiť to jquery ? V oblasti web stránok som zatial len u CSS (ten javascript je z netu skopírovaný).

 

A iframe sa ukončuje </iframe>, pretože keď som to dal preč, tak mi nezobrazovalo odkazy pod ním...

Link to comment
Share on other sites

  • 0

potom ako končiš <iframe> tak musíš pred > dať / (takže <iframe /> )

nikdy som nepočul žeby sa to ukončovalo ako </iframe> lebo mi to nepasuje, to nie je ako <p> že odstavec </p>

 

jquery sa naučíš aj základy na stránke w3schools.com :d

Link to comment
Share on other sites

  • 0

potom ako končiš <iframe> tak musíš pred > dať / (takže <iframe /> )

nikdy som nepočul žeby sa to ukončovalo ako </iframe> lebo mi to nepasuje, to nie je ako <p> že odstavec </p>

 

jquery sa naučíš aj základy na stránke w3schools.com :d

no keď dám <iframe src...></iframe>A sem nejaky text, tak sa mi ten text zobrazí.

keď dám <iframe src... />Nejaky text, tak sa ten text nezobrazí...

 

pozrem na tú stránku, dík

Link to comment
Share on other sites

  • 0

no keď dám <iframe src...></iframe>A sem nejaky text, tak sa mi ten text zobrazí.

keď dám <iframe src... />Nejaky text, tak sa ten text nezobrazí...

 

pozrem na tú stránku, dík

ak by si ešte niečo potreboval, napíš SZ

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...