Order of reload commands in Javascript
Quick javascript question. Let's say I'm trying to retrieve keyword
metadata from Youtube. Since Youtube navigation is AJAX, the keyword
metadata doesn't reload every time the url changes. For example, if I
type:
document.getElementsByTagName('meta')[2].content.split(',');
into the console at the first youtube video I hit, it gives me the first
video's keywords. However, when I click on "relevant videos" on the
sidebar, navigate to a second video and enter the same command, it still
gives me the first video's keywords. So, I tried running this series of
commands:
location.reload(true);
document.getElementsByTagName('meta')[2].content.split(',');
But the order is off; javascript executes the second before it executes
the first. Thus, the first video's tags are still returned, despite the
reload. (All variations of reload, ex: window.location = window.location,
location.reload(false) return similar results.)
How can I control the order of the commands so that the reload comes
before the meta-data call?
context: I am working on a Chrome extension, so I cannot simply separate
these lines on different console command lines.
No comments:
Post a Comment