Using regular expressions:
var stringEx = '<iframe width="560" height="315" src="//www.youtube.com/embed/spr0ZHC2x2o" frameborder="0" allowfullscreen></iframe>';
var width = /width="(\d+)"/.exec(stringEx)[1]; //looks for a match in the stringEx string
var height = /height="(\d+)"/.exec(stringEx)[1];
console.log(width); //560
console.log(height); //315
NOTE: If the match succeeds, the exec() method returns an array.
The returned array has the matched text as the first item,
and then one item for each capturing parenthesis that matched containing the text
that was captured