Javascript XPATH and Sleep

If you need to select an element via JavaScript and XPATH you could use this code.In line 4 I make a sleep about 10 Seconds and then open the link in the same window.

var XPATH =('//div[@class="nfo"]/pre/a[contains(@href,"imagecurl.org")]');
//alert(XPATH);
var link = document.evaluate(XPATH, document.body, null, 6, null).snapshotItem(0);
    setTimeout(function(){window.open(link,"_self")},10000);

 

Leave a Reply

Your email address will not be published.

twenty + eleven =