When I click on link it opens the two new tabs using jquery.This works in firefox but not working in chrome and IE

Priya2026

When I click on link it opens the two new tabs using jquery.This works in firefox but not working in chrome and IE.My Code is:

<script>
$(document).ready(function() {
$("#clickme").on("click", function(event) {
    event.preventDefault();
    window.open("http://localadvertisingthatworks.com?lp_redirect_4779=http://marketing.localadvertisingthatworks.com/acton/attachment/6817/f-001f/1/-/-/-/-/A%20guide%20to%20Local%20Advertising.pdf&amp;wp-cta-v=0&amp;wpl_id=TbfyVCtDihutDKsQUF8xD62LGQTWMJ369hN&amp;l_type=wpluid");     
    window.open("http://localadvertisingthatworks.com/download_thanks/");
    
     
    
});
});
</script>
<a class="inbound-button inbound-special-class" style="background-color: #2da8d2; border-color: #2da8d2; color: #fff; margin-right: 15px;" href="#" id="clickme" target="_blank"><i class="fa-download"></i>Download File</a>

Justinas

Since chrome allows only one URL open per user action (clicking second time on your link will open second link) you must simulate opening (working example, just allow pop-ups, don't know why need that on chrome; can't use SO Snippet as it prevents new tab opening):

<html>
    <head>
        <script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
    </head>
    <body>
        <a class="inbound-button inbound-special-class" style="background-color: #2da8d2; border-color: #2da8d2; color: #fff; margin-right: 15px;" href="#" id="clickme" target="_blank"><i class="fa-download"></i>Download File</a>
        <script type="text/javascript">
            $(document).ready(function() {
                $("#clickme").on("click", function(event) {
                    event.preventDefault();

                    // random ID that will not match any other link on page.
                    var id1 = 'mrl-by-jj-'+Math.floor(Math.random() * 1000);
                    var id2 = 'mrl-by-jj-'+Math.floor(Math.random() * 1000);

                    // create links
                    var a1 = $('<a/>', {
                        href: 'http://localadvertisingthatworks.com?lp_redirect_4779=http://marketing.localadvertisingthatworks.com/acton/attachment/6817/f-001f/1/-/-/-/-/A%20guide%20to%20Local%20Advertising.pdf&amp;wp-cta-v=0&amp;wpl_id=TbfyVCtDihutDKsQUF8xD62LGQTWMJ369hN&amp;l_type=wpluid',
                        target: '_blank',
                        id: id1
                    });
                    var a2 = $('<a/>', {
                        href: 'http://localadvertisingthatworks.com/download_thanks/',
                        target: '_blank',
                        id: id2
                    });

                    // append to body
                    a1.appendTo('body');
                    a2.appendTo('body');

                    // trigger click and remove from DOM
                    $('#'+id1)[0].click();
                    $('#'+id2)[0].click();

                    $('#'+id1+', #'+id2).remove();
                });
            });
        </script>
    </body>
</html>

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

From Dev

jQuery click event works in Chrome, not in Firefox or IE

From Dev

When I click a link in Google Chrome the Thunderbird Account Wizard opens

From Dev

Chrome tabs getting closed when i click on any link

From Dev

JQuery Code works in chrome and IE but it not works in firefox

From Dev

JQuery Code works in chrome and IE but it not works in firefox

From Dev

CSS not working with IE and Firefox, but works in Chrome

From Dev

CSS not working in IE or Firefox - Chrome works fine

From Dev

JS not working in Firefox, works in IE and Chrome

From Dev

RSS XML not working in IE works in Chrome and Firefox

From Dev

JavaScript not working in IE and Firefox, works fine in Chrome

From Dev

Python IIS is not working in FireFox, but works in IE and Chrome

From Dev

Can't click link with negative z-index on IE11 but works on Chrome, Firefox, Edge?

From Dev

Protractor click not working in IE, but works in chrome

From Dev

Jquery touch punch works for Chrome and Firefox but not IE

From Dev

Jquery Javascript only works on chrome and firefox, but not on IE

From Dev

Jquery touch punch works for Chrome and Firefox but not IE

From Dev

MVC JQuery DatePicker not working in ie (works in Chrome)

From Dev

jQuery working in Chrome and Safari, but not Firefox or IE?

From Dev

Jquery error() working in chrome and IE but not firefox

From Dev

jquery $.ajax call results in 401 unauthorized response when in Chrome or Firefox, but works in IE

From Dev

jQuery Click function working in Firefox but not Chrome/Safari

From Dev

Opening a link in a new tab is working for Firefox but not working for Chrome browser using Selenium

From Dev

Css not working(rendering) in chrome/firefox but works in IE10/Edge

From Dev

Kendo UI Grid resizable not working in IE but works fine in Chrome and Firefox

From Dev

link from page two not going back to id on previous page in firefox, see code below. works in IE, O, Saf and Chrome

From Dev

Web site footer is out of whack when i test it in firefox/IE however works fine in Chrome

From Dev

How to stop getting error message and two tabs when I ctrl + click on a link in gnome terminal

From Dev

jQuery fadeIn fadeOut "blink" on Chrome, works fine on FireFox and IE

From Dev

jquery-issue with load(): works with Firefox and Safari, not with Chrome, Opera and IE

Related Related

  1. 1

    jQuery click event works in Chrome, not in Firefox or IE

  2. 2

    When I click a link in Google Chrome the Thunderbird Account Wizard opens

  3. 3

    Chrome tabs getting closed when i click on any link

  4. 4

    JQuery Code works in chrome and IE but it not works in firefox

  5. 5

    JQuery Code works in chrome and IE but it not works in firefox

  6. 6

    CSS not working with IE and Firefox, but works in Chrome

  7. 7

    CSS not working in IE or Firefox - Chrome works fine

  8. 8

    JS not working in Firefox, works in IE and Chrome

  9. 9

    RSS XML not working in IE works in Chrome and Firefox

  10. 10

    JavaScript not working in IE and Firefox, works fine in Chrome

  11. 11

    Python IIS is not working in FireFox, but works in IE and Chrome

  12. 12

    Can't click link with negative z-index on IE11 but works on Chrome, Firefox, Edge?

  13. 13

    Protractor click not working in IE, but works in chrome

  14. 14

    Jquery touch punch works for Chrome and Firefox but not IE

  15. 15

    Jquery Javascript only works on chrome and firefox, but not on IE

  16. 16

    Jquery touch punch works for Chrome and Firefox but not IE

  17. 17

    MVC JQuery DatePicker not working in ie (works in Chrome)

  18. 18

    jQuery working in Chrome and Safari, but not Firefox or IE?

  19. 19

    Jquery error() working in chrome and IE but not firefox

  20. 20

    jquery $.ajax call results in 401 unauthorized response when in Chrome or Firefox, but works in IE

  21. 21

    jQuery Click function working in Firefox but not Chrome/Safari

  22. 22

    Opening a link in a new tab is working for Firefox but not working for Chrome browser using Selenium

  23. 23

    Css not working(rendering) in chrome/firefox but works in IE10/Edge

  24. 24

    Kendo UI Grid resizable not working in IE but works fine in Chrome and Firefox

  25. 25

    link from page two not going back to id on previous page in firefox, see code below. works in IE, O, Saf and Chrome

  26. 26

    Web site footer is out of whack when i test it in firefox/IE however works fine in Chrome

  27. 27

    How to stop getting error message and two tabs when I ctrl + click on a link in gnome terminal

  28. 28

    jQuery fadeIn fadeOut "blink" on Chrome, works fine on FireFox and IE

  29. 29

    jquery-issue with load(): works with Firefox and Safari, not with Chrome, Opera and IE

HotTag

Archive