JavaScript Problems

Get help with installation and running phpwcms here. Please do not post bug reports or feature requests here.
Post Reply
dustin-lee
Posts: 4
Joined: Sun 12. Nov 2006, 17:00
Location: Nebraska
Contact:

JavaScript Problems

Post by dustin-lee »

Hello,

I'm trying to use this JavaScript:

Code: Select all

</head>
<script type="text/javascript">
function autofitIframe(id){ // v.1.0
//copyright 2004 Eddie Traversa http://www.dhtmlnirvana.com/
if (!window.opera && !document.mimeType && document.all && document.getElementById){
parent.document.getElementById(id).style.height=this.document.body.offsetHeight+"px";
}
else if(document.getElementById) {
parent.document.getElementById(id).style.height=this.document.body.scrollHeight+"px"
}
}
</script>

<body onload="autofitIframe('Entrycontainer')">
But it needs to go in between the </head> and <body>.

I've tried using:

Code: Select all

$content['page_start'] .= '  <script src="'.TEMPLATE_PATH.'inc_js/cwf.js" type="text/javascript"></script>'.LF;
But that doesn't work. I've tried using it in the template area but that doesn't work either. And I've also been using body onload="autofitIframe('Entrycontainer') in the JS onload in the templates area.

Does anyone know how I can add this code in between the </head> and <body>?

Any help would be much appreciated!
User avatar
Oliver Georgi
Site Admin
Posts: 9934
Joined: Fri 3. Oct 2003, 22:22
Location: Dessau-Roßlau
Contact:

Post by Oliver Georgi »

never use body onload anymore!!!

Have a look at template there you can find a field "JS onload".

Otherwise put the JavaScript at bottom of your template near the closing </body> so that it is the last which is loaded when page is rendered. Works almost.

Oliver
Oliver Georgi | phpwcms Developer | GitHub | LinkedIn
Post Reply