Ok I have two pages:
Page A with ajax tabs Page B with select menu
on page B in the select drop down box, I have:
<form name="mssgMenu">
<div class="field2">
<select id="moreActions" name="moreActions" class="small" onchange="if(this.options[this.selectedIndex].value != ''){window.top.location.href=this.options[this.selectedIndex].value}">
<option selected="selected" value="">More Actions
<option value="">Inbox
<option value="">Sent Mail
<option value="">Compose new Message
<option value="pageA.php#tab4">bugMe
</select>
</div>
</form>
On Pa开发者_如何学编程ge A I have the tab ( lets say tab 4 referenced as )
<li><a href="#tab4"><span class="Mssg">HelloWorld</span></a></li>
So how do I get the select box, link to hyperlink and to open the tab ?page
you can execute url and then on another page use parameter #tab2 with javascript to open it
function activateTab() { var params = document.location.toString().split('#'); if(params.length > 0) { //code to activate tab } }
If you are using jQueryUI tabs, do these
On Page B change last option like this
<select id="moreActions" name="moreActions" class="small" onchange="if(this.options[this.selectedIndex].value != ''){window.top.location.href=this.options[this.selectedIndex].value}">
<option selected="selected" value="">More Actions</option>
<option value="">Inbox</option>
<option value="">Sent Mail</option>
<option value="">Compose new Message</option>
<option value="pageA.php?selected=tab4">bugMe</option>
</select>
And on Page A
$(document).ready(function () {
if (getParameterByName("selected") == "tab4") {
$("#MyTabs").tabs({
selected: 3
});
}
});
function getParameterByName( name )
{
name = name.replace(/[\[]/,"\\\[").replace(/[\]]/,"\\\]");
var regexS = "[\\?&]"+name+"=([^&#]*)";
var regex = new RegExp( regexS );
var results = regex.exec( window.location.href );
if( results == null )
return "";
else
return decodeURIComponent(results[1].replace(/\+/g, " "));
}
精彩评论