vendredi 13 février 2015

Finding the Offset of a


PROBLEM: Can't get the offset of a <frame> using jQuery (v2.1.3) + phantomJs (v2.0) because $('frame') can't find any frame.


QUESTION: How can I access the offset of the 2nd frame in the page?


DETAILS: I'm running a phantomjs script to access a webpage (link) and fetch a specific Captcha image. The markup of the page is:



<frameset>
<frame></frame>
<frame>The image is inside this frame!</frame>
</frameset>


And the image that I'm searching for is inside the second <frame> and it has an id of #imgCaptcha. I'm using this script (which is not working) to try to get the offset of the frame:



page.open(url, function (status) {

console.log("Status: " + status);
if (status === "success") {
page.render('example.png');
} else {
phantom.exit();
}

page.includeJs('http://ift.tt/1vhyxae', function () {
var frame_offset = page.evaluate(function () {
var frame_offset = [];
$('frame').each(function () {
frame_offset.push($(this).offset().top);
});
return frame_offset;
});
console.log(frame_offset.length);
});
phantom.exit();
});


I'm also running the following error handling functions (callback functions): onResourceError ,onError ,onResourceTimeout ,onConsoleMessage . However, they don't display any information (no error).


Thanks for helping!!!! :DDD





Aucun commentaire:

Enregistrer un commentaire