SCRIPTS php html javascript navigateur page web informatique
 
telecharger la barre d'outils
              astuces ICI

 

marge

Comment ajuster une page html à son contenu ?

Ajuster une frame à son contenu.

 

Oui, je sais, un include en php vaut mieux que toutes les frames en html ! Il n'empêche que ce script m'a bien rendu service et qu'il rendra encore servie à d'autres... J'ai dit ! Hug !

 

1) Mettre dans la partie head de la page qui appelle :

<!--script ajustement iframe -->
<script type="text/javascript">
function adjustIFrameSize (iframeWindow) {
if (iframeWindow.document.height) {
var iframeElement = document.getElementById
(iframeWindow.name);
iframeElement.style.height = iframeWindow.document.height + 'px';
iframeElement.style.width = iframeWindow.document.width + 'px';
}
else if (document.all) {
var iframeElement = document.all[iframeWindow.name];
if (iframeWindow.document.compatMode &&
iframeWindow.document.compatMode != 'BackCompat')
{
iframeElement.style.height =
iframeWindow.document.documentElement.scrollHeight + 5 + 'px';
iframeElement.style.width =
iframeWindow.document.documentElement.scrollWidth + 5 + 'px';
}
else {
iframeElement.style.height =
iframeWindow.document.body.scrollHeight + 5 + 'px';
iframeElement.style.width =
iframeWindow.document.body.scrollWidth + 5 + 'px';
}
}
}
</script>

et dans le body :

<<iframe name="iframeName" id="iframeName"
marginwidth="1" marginheight="0"
src="index.php" style="width: 979px" scrolling="no" border="0" frameborder="0">
<div class="style1">
<a
href="index.php">page</a></div>
</iframe>

 

2) Mettre dans le body de la page appelée :

<body onload="if (parent.adjustIFrameSize)
parent.adjustIFrameSize(window);"
>
<script type="text/javascript">
var lines = Math.floor(Math.random() * 100) + 25;
for (var i = 0; i < lines; i++)
</script>
</body>

 


marge

 

.