When a user is on the home page, he can click on a link that redirects him to another page (so far, it works).
In the new page, I would like the link to automatically open the second tab of a table by doing an "auto click" (trigger).
The link of the home page is specific (it has an anchor).
I managed to make a script that works, the problem is that if I open this page from the navigation menu, the second tab of the table still opens.
I would like that only the specific link can automatically open the second tab of the table.
Here is the code I used:
$(document).ready(function(){
$('#test').click(function(){
console.log('clicked');
});
// set time out 5 sec
setTimeout(function(){
$('.et_pb_tab_3 > a').trigger('click');
}, 500);
console.log('triggered');
});
Thanks a lot for helping.
Best regards,
Johann
2
Answers
Ok so it was easy and i'd like to thanks @Branson Smith for inspiration.
i just had i conditional statement to check if there is a hash in the url :
A url parameter may get the job done for you. From the link you want to open you could do something like:
example-link.com?showTable=True
.Then look for that url parameter on the new page and only open if it’s there and True.
example-link.com#rebozo?showTable=True
https://www.sitepoint.com/get-url-parameters-with-javascript/