I am using the html tab tag to show different tabs in my salesforce page. When I am on my second tab, an operation requires me to reload the window. I use window.loaction.reload() for the same.

But unfortunately, when I reload the window the control gets shifted to first tab. Is there a way I can set the second tab as active on window reload?

Any help is appreciated.



Instead of window.loaction.reload() use window.location.href=window.location.pathname + '?activeTab=second', then you should have additional JS code for retreiving url param:

window.onload = function(){ var activeTab = decodeURIComponent((new RegExp('[?|&]activeTab=([^&;]+?)(&|#|;|$)').exec(location.search)||[,""])1.replace(/+/g, '%20'))||null; if(activeTab === 'second'){//activate first tab} else {//do something?} }

Additionally, here is a solution how to retrieve url parameter using JS so that use it instead of JS code mentioned above.

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.