<a href="и_тут_реальная_ссылка_на_pdf" rel="alternate" type="application/pdf">pdf</a>
<a href="и_тут_реальная_ссылка_на_pdf" rel="alternate" type="application/pdf" target="_blank">pdf</a>
$(document).on('click', 'a[rel="alternate"][ty[e="application/pdf"]', function (e) {
e.preventDefault();
var $link = $(this),
printWindow = window.open($link.attr('href'), '_pdf', 'width=600,height=800');
$(printWindow).on('load', function () {
this.print();
});
});
<a href="и_тут_реальная_ссылка_на_pdf" rel="alternate" type="application/pdf">pdf</a>
var result = {};
$(function () {
var links1 = $('#navCatLvl1 a'),
index = 0,
observer = new MutationObserver(function (e) {
var nodes = checkInsertion(e[0].addedNodes);
});
observer.observe(document.querySelector('#childCategories'), {
childList: true
});
simulateClick(0);
function simulateClick (index) {
result[links1.eq(index).data('catid')] = {
url: links1.eq(index).data('filter-url'),
text: links1.eq(index).data('text'),
sub: {}
};
links1.eq(index).trigger('click');
}
function checkInsertion (nodes) {
for (var i = 0; i < nodes.length; i++) {
if (nodes[i].nodeType == 1) {
var elems = $(nodes[i]).find('[data-level]');
elems.each(function () {
var $item = $(this);
result[links1.eq(index).data('catid')].sub[$item.data('catid')] = {
url: $item.eq(index).data('filter-url'),
text: $item.eq(index).data('text'),
sub: {}
}
});
index++;
if (links1.eq(index).length) {
//simulateClick(index);
}
}
}
}
console.log(result);
});
var observer = new MutationObserver(
function (e) {
var nodes = e[0].addedNodes;
for (var i = 0; i < nodes.length; i++) {
if (nodes[i].nodeType == 1) {
var elems = $(nodes[i]).find('[data-level]');
elems.each(function () {
var $item = $(this);
console.log($item.data());
});
break;
}
}
}
);
observer.observe(document.querySelector('#childCategories'), {
childList: true
});