Question : PHP/Javascript newbie - need help integrating niftycube into my site

I've found code at http://www.html.it/articoli/niftycube/index.html that I hope will integrate into my Joomla site to give me the look the designer has specified.

My problem is that I don't understand how to correctly call the javascript function from my INDEX.PHP file, as it doesn't work as I hoped.

 
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
<script type="text/javascript" src="templates/<?php echo $this->template ?>/js/niftyLayout.js" />
<script type="text/javascript" src="templates/<?php echo $this->template ?>/js/niftycube.js" />


</head>
<body>
<!-- <script type="text/javascript">window.onload=function(){Nifty("div#box","big")} /> -->
<script type="text/javascript" onload="Nifty('div#box','big')" />
<div id="box">
<div id="header">


I'm looking for help in debugging why it is not working. Are my CSS files for the NiftyCube function not in the right place? Is the function NIFTY() being called incorrectly?

Any assistance most appreciated!

Answer : PHP/Javascript newbie - need help integrating niftycube into my site

This specific code looks fine from what I can tell.  Try using an alert('hello!') instead of Nifty(...) or put alert('hello!') as the first line of code inside the Nifty method implementation to see if you're using it correctly.  If the alert occurs, then the code inside of the Nifty method is not correct.  If the alert doesn't occur, then you're calling the method incorrectly from onload.

Here is a link:  http://wap.w3schools.com/jsref/event_body_onload.asp

Onload shouldn't necessarily be trusted though, specifically in the Opera web browser.  In Opera, onload is only called the very first time the webpage is loaded and stored into the cache.  So onload will NOT be called again until the temporary internet files/cache/etc. are deleted.  I'm not sure if this is true for other web browsers.  The way to get around it is to just call the method inside the script code without onload:

<script type="text/javascript">
Nifty("div#box","big");
</script>
Random Solutions  
 
programming4us programming4us