Amir
Amir

Reputation: 2126

How to automatically click a href?

I got videos list using AJAX, and me want to play a top video an a light box? So after viewing list how it is possible to play video automatically?

Upvotes: 2

Views: 5769

Answers (1)

Aaron Saunders
Aaron Saunders

Reputation: 33335

html code

<a id="a_lnk" href="http:\\www.cnn.com">cnn</a>​

javascript code

// find a <a> element with id a_lnk
var lnk = document.getElementById('a_lnk');
lnk.onclick = function(e){
  // do the magic here..
  // e.target is the object that got the click
    window.location = e.target.getAttribute('href');
  return false;
}​

complete example here

http://jsfiddle.net/eAFWY/26/

can also be done with jQuery if that is your thing

http://api.jquery.com/click/

Upvotes: 3

Related Questions