last day (15 days later) » 

10:00 AM
0
A: jQuery Issue about Continue button opens external link in multiple browser tabs

madalinivascuDon't inline your events, you may try something like this: $('a').each(function() { //add a class to all external links var $a = jQuery(this); if ($a.get(0).hostname && getDomain($a.get(0).hostname) != currentDomain) { $a.addClass('modalOpen'); } }); $('....

 
using this code, a modal popup is not opened, it directly redirect to external link
 
make sure that your external links have a .modalOpen class
 
Yes..it has class="modalOpen"
 
the click event doesn't seem to work, updated my answer
 
I am not getting you about click event doesn't seem to work,what can I do now?
 
10:00 AM
do you get any console errors?
 
No..as it directly redirects to external link
 
sory my bad its event.preventDefault();
 
It shows the modal popup but when I click on continue button it does not redirect to external link. It redirect to current page in same tab. I think " $('.selected').click();" function not working as per expectations.
I just console the $('.selected') & found below response. e.fn.init [a.modalOpen.selected, selector: ".selected", prevObject: n.fn.init(1), context: document] Actually, it should be "<a href="test.in/&quot; target="_blank" rel="noopener noreferrer" class="modalOpen selected">My Gov</a>"
 
if you console $('.selected') you will get a jquery object not a html dom element
remove the location reload, i think it interfere with the click event
 
It closes the modal popup only :(
I think $('.selected').click() will not work click event as it will get jQuery object
 
10:00 AM
try $('.selected').trigger('click'); instead of $('.selected').click();
 
Same result...It closes the modal popup only
I think, $('.selected') object does not have the external link value
 
do a console.log( $('.selected')[0]) and paste it here
 
<a href="test.in/&quot; target="_blank" rel="noopener noreferrer" class="modalOpen">My Gov</a>
 
so the element is good but the click doesn't trigger , try $('.selected').unbind('click').trigger('click');
 
Same result...nothing happens..It closes the modal popup only
had checked with trigger but still facing same issue. It closes modal popup only..
 
10:00 AM
there may be something else interfering with your click event
 
Yes..I have also tried with different tricks but still not able to redirect with external links :(
 
have you tried window.open($('.selected').attr('href'),'_blank')?
 
That's great @mandalinivascu... Thanks a lot.. :)
 

last day (15 days later) »