How to trigger an event in Mootools for a specific tag/element with a specific element ID?

StackOverflow https://stackoverflow.com/questions/8234244

سؤال

How to trigger an event in Mootools for a specific tag/element with a specific element ID?

I have this:

<a href="youtube-clip...etc" rel="rokbox" id="video_popup" style="display: none;">Video</a>

This rel="rokbox" means that the element will be used by the Mootools RokBox modal box, but I've hidden the link.

Now, I've added this code:

window.onload = function() {
  if(document.readyState == 'complete') {
    // point of execution
    // here I want to trigger the "a" element I've wrote up before
  }
}

The code reaches until the "point of execution", when I set a basic alert, or whatsoever.

هل كانت مفيدة؟

المحلول

window.addEvent('domready', function() {
    $('video_popup').fireEvent('click');
});

Note the use addEvent/domready, which is the proper method to add a function which must execute once the page is ready.

مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top