I recently decided to use one of the cool new features of Dreamweaver CS3 in a site I was developing – the Spry AJAX Framework – more specifically the Spry Tab widget. After Googling for a bit I couldn’t seem to find any page that showed how to make the tabs switch by clicking a link either inside the content of the tab or somewhere else on the page.
The first link I found recommended using the query string of the URL to tell Spry that you wanted to open a different tab. Although this approach works, it requires including another javascript file and adding a bunch of unnecessary syntax at the end of your links. Since many sites already do this when they’re loading actual pages, I think this method could get confusing. This method, however, is the only way to make it so your browser’s back button will work between tabs.
It turns out, after browsing the SpryTabbedPanels.js file, this is pretty easy to accomplish with plain javascript (if you don’t mind the back button functionality not working). You will be invoking the showPanel() method of your tab control. You must call this function on the main tab control’s id. Below is an example of what it would look like if your Tab Control was named “TabbedPanels1” (the default in Dreamweaver CS3).
-
<a href="javascript:TabbedPanels1.showPanel(1);">Click Here to Switch to Tab 2</a>
[…] tagged spryOwn a WordPress blog? Make monetization easier with the WP Affiliate Pro plugin. Spry Tab Switching with Regular Links saved by 14 others YetiLuigi bookmarked on 04/16/08 | […]
I just wanted to say thank you. This has saved me from a series of large headaches. You should definately write more of these simple solutions to simple problems because from what i’ve seen (or rather haven’t seen) you’re the only one willing to post them for others to see.
Tristan, glad I could be of service! I plan on writing more of these types of blogs in the future, if and when I ever get a little free time 🙂
Thanks for sharing. Very good stuff to know. I’m new at the whole spry thing and was wondering how the heck to link to it ! Thanks again !
T-
Hi,
Thank you VERY much for this simple answer, I have been looking for a way to do this for MONTHS. As you can see, my site is built entirely using Spry Tabs.
However, I would like to use a sliding menu bar built in Flash CS3 as my ‘tabs’. I have managed to get the menu in place by reducing the size of the default tabs in DW, making them invisible and right floating them. I inserted my Sliding Menu as a Flash movie inside a Div floated left. The positioning worked but I cannot find a way to link the buttons on the menu in ActionScript to the relevant Tabs as in the example above. ActionScript will not accept this code. Do you have any idea what command I would use to do this.
Thanks
Ian,
I’m assuming you’re not using Javascript Syntax – “javascript:”? You can link directly to Javascript by doing something like this (in ActionScript 3):
var request:URLRequest = new URLRequest(“javascript:TabbedPanels1.showPanel(1);”);
navigateToURL(request);
The key point is making sure javascript: is in there so the browser knows it’s not going to a directory with that name in the site.
If that doesn’t fix it let me know!
Ian,
My above code doesn’t work you actually need to make sure you have the “_self” window property set in navigateToURL(); The below worked for me:
var request:URLRequest = new URLRequest(“javascript:alert(‘test’);”);
navigateToURL(request, “_self”);
Now just change “javascript:alert(‘test’);” to ”javascript:TabbedPanels1.showPanel(1);”
Hi Adam,
Thanks for your help.
I couldn’t get it to work. This is what I did.
I made a button in Flash CS3, right clicked on the first (only) keyframe of the button, chose ‘actions’ and inserted the code like this;
var request:URLRequest = new URLRequest(javascript:TabbedPanels1.showPanel(1);)
navigateToURL(request, “_self”);
It threw back mostly syntax errors.
I am using ActionScript 3.0
You need to use quotes in the first line, should be URLReuqest(“javascript:…..”); That is probably causing the syntax errors.
Hi Adam,
Still no good.
For the first line I get;
1084: Syntax error: expecting rightparen before colon.
1083: Syntax error: rightparen is unexpected.
And for the second line;
1093: Syntax error.
(repeated 4 times)
Maybe I am putting the script in the wrong place.
I will try different ways of creating the button.
Thanks for your help.
Hi,
I found out on the ActionScript.org forum that the way to go is by using an ActionScript ‘ExternalInterface Class’ – Call ( ) to get the JavaScript going.
I haven’t figured out how to use it yet but I’m getting closer.
I suppose this info may help others trying to use JS and Flash, so I thought I’d post.
Thanks again.
This totally saved my life today! Thanks a bunch! Anything on linking to a specific spry tab from another page? If you can answer that – I think that would just about solve every problem I’ve ever had! Well, almost…
Thank you for this. Here is an article I found on how to specify a tab from a different page:
http://foundationphp.com/tutorials/spry_url_utils.php
worked like a charm. Thank you for the tip.
Thanks for this, a very elegant and easy to use solution
Cheers
I was going crazy looking through the Spry javascript. Your example was an answered prayer. Thank you so much.
Check it out and rate it for me!
I believe one needs to do an IgG or IgM test, or both, one tests for
recent herpes infection, the other tests for any infection episode at any time prior.
Having read this I thought it was rather informative.
I appreciate you spending some time and effort to put this article together.
I once again find myself spending a lot of time both reading and commenting.
But so what, it was still worthwhile!
عالی است مطلب گردآوری شده توسط شما چقدر خوب ایجاد الفت کردن
شده است و من مطمئن هستم که این پست از باب کثیر از وبلاگ نویسان مرضی است
Have you ever thought about creating an ebook or guest authoring on other blogs?
I have a blog centered on the same information you discuss and would love to
have you share some stories/information. I know my viewers
would appreciate your work. If you are even remotely interested, feel free to shoot me an e-mail.
من این مطلب را خواندم و می توانم این یادداشت را به افراد دیگر کرب پیشنهاد
کنم
من آسوده خاطری هستم که تو تمام اینترنت مطلب مانند
به این نبا حیات ندارد برای اینکه مطلب طولانی
و کمال یافته ی پیرامون این مبحث است
کنیز تا به اوضاع مطلب به این
تزیین در اینترنت نخوانده بودم بسیار جذاب
و آزگار بود و مقاله جالب آنها برای بی مر از ملاقات کنندگان اینترنت کم قیمت است
commonly associated with
manuscripts significantly
way. Handwritten book
works of art.
By the end of the 15th century, 35
One of the most skilled calligraphers
ancient and medieval Latin,
By the end of the 15th century, 35
… As a rule, the manuscript is called
(palimpsests). In the XIII-XV centuries in
من دل آسوده هستم که داخل آزگار اینترنت یادداشت مثل بوسیله
این یادداشت حیات ندارد برای اینکه مطلب آزگار و جامع ی پیرامون این مبحث است
Many calligraphers have acquired
only a few survived.
One of the most skilled calligraphers
“Julia’s Garland” (fr. Guirlande de Julie)
book about the chess of love “, created by
from lat. manus – “hand” and scribo – “I write”) ]
book about the chess of love “, created by
handwritten books were made,
من تامین هستم که داخل آزگار اینترنت
مطلب مانند به این نبا بود ندارد برای
اینکه مطلب آزگار و تمامیت ی پیرامون این مبحث است
معنای مطلب ی این یادداشت از نظر مفرط از افراد کم ارزش و کامل نیست ولی جانباز از مطالب مرکز
مجازی در اینترنت ها و بلاگ ها پیرامون این مطلب در وب وجود دارند
که می توان از آنها استفاده بهتری داشت
book about the chess of love “, created by
bride, Julie d’Angenne.
from lat. manus – “hand” and scribo – “I write”) ]
(palimpsests). In the XIII-XV centuries in
book about the chess of love “, created by