Page 1 of 1

iFrame and Javascript?!?!

Posted: Tue Jun 24, 2008 7:26 pm
by jmansa
I'm trying to make and dynamic iframe wich is dynamic in height. I found a perfectly good script and it works like a charm outside cmsms, but inside... Nothing happens. Can anybody tell me why, and if it can be done, how???

The script:

Code: Select all

<__script__ language="JavaScript">
function iFrameHeight() {
if(document.getElementById && !(document.all)) {
h = document.getElementById('iframename').contentDocument.body.scrollHeight;
document.getElementById('iframename').style.height = h;
}
else if(document.all) {
h = document.frames('iframename').document.body.scrollHeight;
document.all.iframename.style.height = h;
}
}
</__script>
And then the actually iframe:

Code: Select all

<__iframe 
onLoad="iFrameHeight();" 
src="index.php" 
scrolling="no" 
scroll="no" 
id="iframename" 
marginwidth="0" 
marginheight="0" 
frameborder="0" 
style="width:100%;">
</__iframe>

Re: iFrame and Javascript?!?!

Posted: Wed Jun 25, 2008 1:25 am
by Dr.CSS
Where and how are you trying to use it in CMSMS?...

Re: iFrame and Javascript?!?!

Posted: Wed Jun 25, 2008 5:57 am
by jmansa
I have inserted the javascript in a template like this:

Code: Select all

<head>
<title>{topsite} - {title}</title>
{metadata}
{stylesheet}
<__script__ type="text/javascript" src="js/swfobject.js"></__script>
{literal}
<__script__ language="JavaScript">
function iFrameHeight() {
if(document.getElementById && !(document.all)) {
h = document.getElementById('iframename').contentDocument.body.scrollHeight;
document.getElementById('iframename').style.height = h;
}
else if(document.all) {
h = document.frames('iframename').document.body.scrollHeight;
document.all.iframename.style.height = h;
}
}
</__script>
{/literal}
</head>
</__body>
And in the body of site I have inserted the iframe:

Code: Select all

<div id="content">
        	<h1>{title}</h1>
            	<__iframe 
onLoad="iFrameHeight();" 
src="index.php" 
scrolling="no" 
scroll="no" 
id="iframename" 
marginwidth="0" 
marginheight="0" 
frameborder="0" 
style="width:100%;">
</__iframe>
		</div>
I have also just tryied to just insert into a page in the cmsms admin, but with no luck  :-\

Re: iFrame and Javascript?!?!

Posted: Wed Jun 25, 2008 6:25 am
by Dr.CSS
Maybe it has to do with the JS tag not having the type= like the one above it, but it may have more to do with the src="index.php" considering CMSMS has index.php in the root that is used to render the page you are trying to pull it into...

Do you have 2 index.php in your root?...

Re: iFrame and Javascript?!?!

Posted: Wed Jun 25, 2008 8:49 am
by jmansa
The "index.php" is just for show... I use another page called "sponsors/index.php"