Hi,
Is it possible to make tabs to link to another url rather than the same page ?
Thank you in advance
Myrto
Hi,
Is it possible to make tabs to link to another url rather than the same page ?
Thank you in advance
Myrto
it's possible to add a jQuery listener to the tab anchor and redirect that way.
Hello vfxdude! Hope all is well! After 7 months and I'm still trying to solve this :-(
I found this script online
<script>
$(function() {
//initiate tabs
$( "#tabs" ).tabs();
//Determine is the URL contains an Anchor, and what the value is
var anchor = $(document).attr('location').hash; // the anchor in the URL- Thanks Mike!
//now the 3 scenarios we need to handle
if($("#Tab2").find( anchor).size()>0){
//the anchor lives in Tab2
$("#tabs").tabs('select', 1);
}else if($("#Tab1").find( anchor).size()>0){
//the anchor lives in Tab1
$("#tabs").tabs('select', 0);
}else{
var index = $('#tabs div.ui-tabs-panel').index($(anchor)); //Thanks Mike!
if(index >=0){
//the anchor _is_ tab 1 or 2
$('#tabs').tabs('select', index);
}
}
//anchor resides outside tabs, or doesn't exist, take no action
//This line will update our URL anytime a tab is selected - Thanks Mike!
//setting this before now will cause odd behavior
$("#tabs").bind('tabsshow', function(event, ui){document.location =$(document).attr('location').pathname + "#" + ui.panel.id; });
});
</script>
However I'm not sure how to modify it in order to make it work.
Any help would be greatly appriciated!
All the best
After 7 months and I'm still trying to solve thisHire a developer :)
But since I'm nice I'll show you how I would have done it:
<script>jQuery(function($){
$(".tabs > li:eq(1)").click(function() { window.location.href = 'http://wordpress.org'; });
});</script>
this will redirect tab2 (change the eq(1) number to change what tab to redirect) to the url specified. Just add the code in the page together with the tab shortcode.
You are the best! :-)))) Thank you!
just a little update to prevent the tab content from showing before redirecting.
<script>jQuery(function($){
$(".tabs > li:eq(1) > a").click(function(e) {
e.preventDefault();
window.location.href = 'http://wordpress.org';
});
});</script>You must log in to post.