Reputation:
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?
Upvotes: 1
Views: 19493
Reputation: 115
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.
Upvotes: 1