admin管理员组

文章数量:1290935

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 while a site that is working is at . 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.

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. while a site that is working is at http://www.parediabetictestingsupplies.. 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.

Share Improve this question asked Feb 3, 2012 at 18:32 ShaneShane 1,6403 gold badges23 silver badges51 bronze badges 1
  • When it doesn't work, what happens? – Diodeus - James MacFarlane Commented Feb 3, 2012 at 18:36
Add a ment  | 

1 Answer 1

Reset to default 7

At http://www.freestylelitemeter./, MooTools fails to load. You get this error in your JavaScript console:

SCRIPT438: Object doesn't support property or method 'getElement'
mootools.js, line 53 character 97

MooTools extends window with addEvent(). 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:

$(function ()
{
    $('#refer').val(location.href);
});

Are you even using MooTools much? You may be able to switch to jQuery exclusively, and load one fewer library.

本文标签: