1

I want to run a javascript function from the browser console,
I'm trying to do it in Chrome (windows 7) and my function is this:

function playVideo() {
    var popo = document.getElementsByTagName("object");
      for (var i=0; i<popo.length; i++) {
        popo[i].playVideo(); 
      }
  }

normally this function works fine when I fire it from a webpage

<button onclick="playVideo();">play</button>

or

<a href="javascript:playVideo();">play</a>

but if I paste it into the browser console, and I press Return,
it doesn't work and there is this error:
"undefined"
http://oi57.tinypic.com/z1hjc.jpg

What i'm doing wrong?

2
  • you just defined a function. Call it. Commented Mar 22, 2014 at 23:39
  • I've tried to call it, but without success.. I don't understand why... Commented Mar 23, 2014 at 12:54

1 Answer 1

1

After paste to console and pressing return you must call this function by name, in you case, after "undefined" write to consle "playVideo()" and press Return.

Sign up to request clarification or add additional context in comments.

2 Comments

after paste to console, press return, and after "undefined" write "playVideo()" and press enter, it says again: "undefined"...
ooook!!!! I was trying on Jsfiddle! On Jsfiddle it doesn't work, but after that I tried on my website and it works!! thank you!

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.