Here's the piece of my HTML code:
<li>
<a id="section1" href="#" onclick="return false">» Section 1</a>
<ul>
<li><a href="link1.html" target="showframe" id="tab1" name="tab1">Tab 1</a></li>
<li><a href="link2.html" target="showframe" id="tab2" name="tab2">Tab 2</a></li>
</ul>
</li>
It is actually an jQuery Accordion. Now the line $('#section1').click(); or $('#'+section).click(); works, both on IE and Chrome. For inner Anchor tags, I tried using:
$('a#'+tab_name_from_querystring).click();
$('a[name="'+ tab_name_from_querystring+'"]').click();
$('a#tab1').click();
All these don't work in any browser. If I use this:
document.getElementById(tab_name_from_querystring).click().
It works in IE only, not in Chrome.
Any help please?
UPDATE: Here's the complete JavaScript code:
<script type="text/javascript">
var query = window.location.search.substring(1);
var params = query.split('&');
var temp = params[0].split('=');
var section = temp[1].toLowerCase();
temp = params[1].split('=');
var tab = temp[1].toLowerCase();
$(document).ready(function(){
$('#'+section).click();
setTimeout(function(){
$("a[name='tab1']").click(); // Did not work
$('a[name="'+tab+'"]').click(); // Did not work
document.getElementById(tab).click(); // Works only in IE
}, 500);
});
</script>
tab_name_from_querystringis 'tab1' or 'tab2'?queryhas the same value?