iFrame and Javascript?!?!

Talk about writing modules and plugins for CMS Made Simple, or about specific core functionality. This board is for PHP programmers that are contributing to CMSMS not for site developers
Post Reply
jmansa
Forum Members
Forum Members
Posts: 126
Joined: Thu Oct 19, 2006 2:46 pm

iFrame and Javascript?!?!

Post 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>
User avatar
Dr.CSS
Moderator
Moderator
Posts: 12711
Joined: Thu Mar 09, 2006 5:32 am
Location: Arizona

Re: iFrame and Javascript?!?!

Post by Dr.CSS »

Where and how are you trying to use it in CMSMS?...
jmansa
Forum Members
Forum Members
Posts: 126
Joined: Thu Oct 19, 2006 2:46 pm

Re: iFrame and Javascript?!?!

Post 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  :-\
User avatar
Dr.CSS
Moderator
Moderator
Posts: 12711
Joined: Thu Mar 09, 2006 5:32 am
Location: Arizona

Re: iFrame and Javascript?!?!

Post 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?...
jmansa
Forum Members
Forum Members
Posts: 126
Joined: Thu Oct 19, 2006 2:46 pm

Re: iFrame and Javascript?!?!

Post by jmansa »

The "index.php" is just for show... I use another page called "sponsors/index.php"
Post Reply

Return to “Developers Discussion”