0

次のように複数のリンクがあるサイトがあるとします。

www.example.com/product/1
www.example.com/product/2
www.example.com/product/3

また、時々リンクに追跡情報を追加して、自分のサイトがどのように使用されているかを確認できるようにします。たとえば、誰かが製品ブラウザから製品ページにアクセスした場合、refパラメータを設定します。

www.example.com/product/1&ref=pb
www.example.com/product/2&ref=pb
www.example.com/product/3&ref=pb

これに伴う問題は、ユーザーが最初のタイプのリンクにアクセスしてから2番目のタイプのリンクを表示した場合、ブラウザーは正確なURLにのみ一致するように見えるため、:visited疑似クラスが適用されないように見えることです。この意味で「ワイルドカード」をリンクに適用して、ユーザーが最初のタイプまたは2番目のタイプのリンクを表示したときに強調表示されるようにする方法はありますか?

注:この「ref」アーキテクチャを変更することはできません。継承されます。

4

3 に答える 3

2

You might be able to do this with javascript. You could code your links as follows

<a href="www.example.com/product/1" onclick="document.location.href='www.example.com/product/1&ref=ab';return false;">

For anybody with a javascript enabled, you will see the visiting www.example.com/product/1&ref=ab, and their browser will detect all links with href=www.example.com/product/1 as the same link. And style them appropriately according to the :Visited pseudoclass. The only downside is that you won't get ref information for those without Javascript. Whether or not that's an accetable tradeoff depends on your requirements.

You could also do something like:

<a href="www.example.com/product/1" onclick="document.location.href=this.href + '&ref=ab';return false;">

so you don't have to code the url in there twice. You could probably even create a function return the proper link, picking up the ref value from a single place.

于 2010-03-21T17:52:02.547 に答える
0

答えは「いいえ」だと確信しています。

于 2010-03-21T17:14:49.040 に答える
0

If the URL varies by even one character it's not the same URL. So ... no.

于 2010-03-21T17:37:22.540 に答える