javascript - window.open() opening same link twice -
i creating chrome extension clothing website releases items @ time. extension looks set of links contain keywords. if finds links, opens them. if not, refreshes page. accomplish using javascript , jquery. script injected via background script & tabs. here code:
if ($("body").hasclass(" products us")) { var firstitem_link = $("a[href*='mizuno']").attr('href'); var seconditem_link = $("a[href*='schott']").attr('href'); if (firstitem_link && seconditem_link) { window.open(firstitem_link); window.open(seconditem_link); } else { window.location.reload(true); } }
when use code , finds links, opens them numerous times, opposed once each. how can fix this?
Comments
Post a Comment