
Originally Posted by
drmeisner
I have clicked on another tab - say Nictaux - I need rel from this tab passed to script so that the script thinks the address is /census/novascotia/annapolis1861/index.php?annapolis1861tabs=nictaux
You are pulling that value from PHP which can only tell what the address is when the page loads. Keeping that model you would have to reload the page each time you change tabs - totally defeating the purpose of using ajaxtabs.
Here are the important parts of your topmsg script for that:
Code:
var url=("belleisle");
var url1="";
url1=url+".html?tngprint=1";
var message='<a style="font-size:16px;font-variant:small-caps;text-decoration:underline; href=\"#\" onclick=\"window.open(url1)"; title="Click Here To Print This Census Transcription"><img src="http://www.dwaynemeisner.com/tng_print.gif" width="16" height="15" border="0" class="tngmenuicon" vspace="0" hspace="1" alt="Click Here To Print This Census Transcription"/>Click Here To Print This Census Transcription</a> <img src="http://www.dwaynemeisner.com/tng_print.gif" width="16" height="15" border="0" class="tngmenuicon" vspace="0" hspace="1" alt="Click Here To Print This Census Transcription"/>'
The highlighted red is supplied by PHP, as I said, only on page load. So the entire highlighted section only gets worked out once per page load. It may as well all be removed.
To get the same effect to be responsive to the currently selected tab's rel attribute we can change the entire above to just:
Code:
var message='<nobr style="display:block;padding-bottom:3px;"><a style="display:block;padding-bottom:3px;font-size:16px;font-variant:small-caps;" href="javascript:printTranscription();" onclick="window.open(countries.tabs[countries.currentTabIndex].rel + \'.html?tngprint=1\'); return false;" title="Click Here To Print This Census Transcription"><img src="http://www.dwaynemeisner.com/tng_print.gif" width="16" height="15" border="0" class="tngmenuicon" vspace="0" hspace="1" alt="Click Here To Print This Census Transcription"/>Click Here To Print This Census Transcription<img src="http://www.dwaynemeisner.com/tng_print.gif" width="16" height="15" border="0" class="tngmenuicon" vspace="0" hspace="1" style="padding-left:3px;" alt="Click Here To Print This Census Transcription"/></a></nobr>';
The main change is from:
Code:
onclick=\"window.open(url1)";
to:
Code:
onclick="window.open(countries.tabs[countries.currentTabIndex].rel + \'.html?tngprint=1\'); return false;"
But it also includes cleaning up the quoting convention and the addition of the nobr tag wrapper to prevent word wrap in some browsers.
Edit: I later realized that both the original and the replacement code in this post were not generating the intended nor optimal HTML for the topmsg script. What I had earlier works though. And so does the new edited version now in this post. It's more user friendly, looks a little better and uses a true link, so has the expected cursor. Ideally the styles for the tags in it should be placed in a stylesheet though. It makes no changes to the new onclick event.
Bookmarks