window.location.href 的 window.addEvent('domready',function() 的替代品是什么?
我们通过 Joomla 中的“refer”id 将 url 页面传递到我们的管理电子邮件,使用...
window.addEvent('domready', function()
{
document.getElementById('refer').value=window.location.href;
});
此代码适用于某些网站,但不适用于其他网站。我尝试过 jquery 版本,但运气不佳,尽管我愿意接受建议。未通过电子邮件返回 URL 的网站位于 http://www.freestylelitemeter.com,而网站正在运行位于 http://www.comparediabetictestingsupplies.com。我们使用“refer”作为隐藏字段并且所有内容都匹配,所以我相信问题出在 window.addEvent('domready', function() ,除非存在我不知道的冲突。另一个有趣的事情是工作域有更多的脚本文件,过去发现脚本文件之间存在冲突,而较小的站点则没有。
We are passing the url page to our Admin Emails through the 'refer' id in Joomla using ...
window.addEvent('domready', function()
{
document.getElementById('refer').value=window.location.href;
});
This code works on some sites but not others. I have tried a jquery version with little luck, though I am open for suggestions. A site not returning the url via email is at http://www.freestylelitemeter.com while a site that is working is at http://www.comparediabetictestingsupplies.com. We are using 'refer' as a hidden field and everything matches, so I believe the issues is with the window.addEvent('domready', function() unless there is a conflict I am not aware of. Another interesting thing is the working domain has many more script files that has in the past found conflict between script files, while the smaller site has not.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
在 http://www.freestylelitemeter.com/ 上,MooTools 无法加载。您在 JavaScript 控制台中收到此错误:
MooTools 使用
addEvent()
扩展了window
。由于 MooTools 尚未加载,addEvent()
失败并且您的代码永远不会执行。您的 MooTools 版本有问题,请更正该版本,您的问题应该会得到解决。
但是,更好的是,您已经在使用 jQuery。只需将您的代码更改为:
您是否经常使用 MooTools?您也许可以专门切换到 jQuery,并少加载一个库。
At http://www.freestylelitemeter.com/, MooTools fails to load. You get this error in your JavaScript console:
MooTools extends
window
withaddEvent()
. Since MooTools hasn't loaded,addEvent()
fails and your code is never executed.You have a buggy version of MooTools, correct that and your problem should be resolved.
But, better yet, you are already using jQuery. Just change your code to this:
Are you even using MooTools much? You may be able to switch to jQuery exclusively, and load one fewer library.