从阵列打开链接而不触发弹出过滤器

时间:2016-04-03 13:42:55

标签: javascript php jquery

我正在尝试开发一个工具,它从页面获取链接,将它们存储在一个数组中,然后在新选项卡中单击打开。有没有办法在不触发浏览器的弹出垃圾邮件过滤器的情况下实现这一目标?

这是我的代码:

<?php 

    $base = "web.archive.org";
    $time = "/web/20160101000000*/";
    $domain = @$_POST["domain"];

    $ch = curl_init();

    curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
    curl_setopt($ch, CURLOPT_URL, "$base$time$domain");
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
    curl_setopt($ch, CURLOPT_TIMEOUT_MS, 20000); //in miliseconds


    $output = curl_exec($ch);
    curl_close($ch);



    # REPLACES ALL URLs OF WAYBACK MACHINE
    $replacedHrefHtml = preg_replace('/(href=")/', "href=\"https://web.archive.org", $output);


    # REPLACES ALL SRCs OF WAYBACK MACHINE
    $replacedsrc = preg_replace('/(src=")/', "src=\"https://web.archive.org", $replacedHrefHtml);


    #get wbCalendar

    $html = str_get_html($replacedsrc);
    $elem = $html->find('div[id=wbCalendar]', 0);

    #extract the links and store them into an array
    $data = array();
    $open = '';
    foreach($elem->find('a') as $element) {
           $extracted = $element->href;
           $open .= "window.open('{$extracted}'); ";
           $data[] = $extracted;
    }

    echo "<a href=\"#\" class=\"cd-read-more\" onclick=\"{$open}\" style=\"float:left;\">Open multiple links</a>";

&GT;

您可以在此处测试:seotify.com/archive-opener

提前致谢。

1 个答案:

答案 0 :(得分:0)

据我所知,你无法确保弹出过滤器无法捕捉到你。我认为您唯一能做的就是在“点击”事件someElement.onclick = function(){ /*POPUP CODE*/ }中打开窗口(以便响应用户操作触发代码)