Rosetta Code:Village Pump/Language Page Links: Difference between revisions
Content added Content deleted
No edit summary |
No edit summary |
||
Line 39: | Line 39: | ||
var links = document.links; |
var links = document.links; |
||
var i = links.length; |
var i = links.length; |
||
var category = document.location.href.match(/\/Category |
var category = document.location.href.match(/\/Category:([^\/]+)$/)[1]; |
||
while (i-- > 0) |
while (i-- > 0) |
||
links[i].href = links[i].href + "#" + category; |
links[i].href = links[i].href + "#" + category; |
||
}</lang> I haven't tested this very well - just once in Opera from Category:1 to Problem1 (it's almost time to go to bed). |
}</lang> I haven't tested this very well - just once in Opera from Category:1 to Problem1 (it's almost time to go to bed). It will also have the unwanted side effect of changing ALL the links on the page. |
||
::::Beware that these might be used to inject a malicious anchor in somehow (haven't thought it through that far, but I'm convinced it could be done somehow). [[User:BR|BR]] 06:34, 17 November 2010 (UTC) |
::::Beware that these might be used to inject a malicious anchor in somehow (haven't thought it through that far, but I'm convinced it could be done somehow). [[User:BR|BR]] 06:34, 17 November 2010 (UTC) |