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 badges4 Answers
Reset to default 4It 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
版权声明:本文标题:javascript - How can I solve the "Window.onDomReady is not a function" problem? - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1742136734a2422403.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论