admin管理员组

文章数量:1323335

<script type="text/javascript" src="<?php echo $this->baseurl; ?>/templates/mytemplate/javascript/min.js"></script>
<script type="text/javascript">
                                var mooTrans= Fx.Transitions.<?php echo $this->params->get('transition','Sine.easeOut') ?>;
                                window.addEvent('domready',function(){
                                new SmoothScroll({ duration: 500, transition: Fx.Transitions.linear}, window);
                                });
                                </script>

and this is the code in the min.js file:

Window.onDomReady(function() {new DropdownMenu($E('#hornav ul.menu'))});

However, I am getting this error: Window.onDomReady is not a function.

Can you please help me understand what I am doing wrong? Thanx

<script type="text/javascript" src="<?php echo $this->baseurl; ?>/templates/mytemplate/javascript/min.js"></script>
<script type="text/javascript">
                                var mooTrans= Fx.Transitions.<?php echo $this->params->get('transition','Sine.easeOut') ?>;
                                window.addEvent('domready',function(){
                                new SmoothScroll({ duration: 500, transition: Fx.Transitions.linear}, window);
                                });
                                </script>

and this is the code in the min.js file:

Window.onDomReady(function() {new DropdownMenu($E('#hornav ul.menu'))});

However, I am getting this error: Window.onDomReady is not a function.

Can you please help me understand what I am doing wrong? Thanx

Share Improve this question edited Apr 25, 2011 at 20:49 ThiefMaster 319k85 gold badges605 silver badges645 bronze badges asked Apr 25, 2011 at 20:48 YannisYannis 9222 gold badges15 silver badges34 bronze badges
Add a ment  | 

4 Answers 4

Reset to default 4

It seems that you are using MooTools framework and in your code there is addEvent call for domready event:

window.addEvent('domready',function(){
    new SmoothScroll({ duration: 500, transition: Fx.Transitions.linear}, window);
});

In your min.js file you can use the same approach:

window.addEvent('domready',function(){
    new DropdownMenu($E('#hornav ul.menu'))}
});

First of all, there is no Window but only a window. Then there is no onDomReady attribute. There might be ondomready though. However, it's better to use actual even binding.

jQuery and other JavaScript frameworks make this pretty easy by providing helper methods for it, e.g. $(document).ready(...);

You are using MooTools. The proper method for listening to a DOMREADY event is the the following:

window.addEvent('domready',function() {new DropdownMenu($E('#hornav ul.menu'))});

After an Upgrade from Joomla 1.5 to 2.5, I faced this issue. When I used Firefox's Tools > Developer > Web Console to check the error, it was caused by incorrect JS code of Joomla 1.5. When i went to edit the code, I saw the Joomla 2.5 JS code. I viewed the source of the validate.js file in the browser and refreshed the page to get the non cached file from the server. This worked for me. So this was a caching issue.

本文标签: javascriptHow can I solve the quotWindowonDomReady is not a functionquot problemStack Overflow