Here's a good solution ... based on your descriptions / diagrams, as well as thinking it over for previous websites.
Two key concepts to remember ... and all other details:
- Do not show Google things in which you do not display regular users. Doing something complicated here can cause you big problems with them, and in fact it is not necessary.
- Use Progressive Enhancement to give your JavaScript users a better experience.
This can be done as follows:
On your texts page, create a permalink for each explanation, for example:
<a href="/lyrics/ARTIST/SONG?note=NOTEID" onclick="showPopUpExplanation(NOTEID);">lyric snippet here</a>
Please note that we use QueryString (?) Instead of a hash (#) so that Google users (and JS-disabled) see this as a truly unique link URL.
Now use Progressive Enhancement and add onclick handlers to all your .explanation-link links (as shown above or as @Dean) to get inpage pop-ups to work.
You do not need to use # (hash) links at all for your JavaScript users. This is only necessary if you are trying to allow the browser back button to work with AJAX, but since you are showing a pop-up window (presumably with a close button), this is optional.
Users who want to share a specific explanation with their friends will use your short ( /NOTEID ) url. These shortened URLs should be redirected 301 to your real permalink (therefore, search engines do not index both URLs).
Finally, to make permalinks work, use small server-side scripts to immediately see this page pop up . Do something like this:
<?php if (isset($_GET['note'])): ?> <div id="explanation"> <?php printExplanation((int)$_GET['note']); ?> </div> <script type="text/javascript"> $('#explanation').hide(); </script> <?php endif; ?>
The important part here is that you print the explanation in HTML , not JavaScript / JSON, so that Google and non-JS users can see it, but gradually improve the JS users.
philfreo
source share