src/cm/media/js/site/c_text_view_comments.js
changeset 184 0d9a2a99ffda
parent 144 e7e1bc64f613
child 186 04644502cb79
--- a/src/cm/media/js/site/c_text_view_comments.js	Sat Feb 13 12:50:06 2010 +0100
+++ b/src/cm/media/js/site/c_text_view_comments.js	Sat Feb 13 13:38:08 2010 +0100
@@ -182,20 +182,30 @@
 	CY.on('resize', onFrameScroll, window, this, true);
 };
 
-// serious tests were made : various browsers + comments on a link.
 preventLinksInText = function() {
 	var interceptLink = function(e) {
-		e.preventDefault();
-
 		var a = e.target;
-		while (a != null && a.get("href") == null) {
+		var href = null;
+		while (a != null && href == null) {
 			a = a.get('parentNode');
+			href = a.get("href");
 		}
-
-		if (a != null && a.get("href") != null) {
-			window.open(a.get("href"));
+		
+		if (a != null && href != null) {
+			//alert(window.location) ;
+			var loc = (new String(window.location)) ;
+			
+			var clean_window_location = loc ;
+			
+			var ind = loc.indexOf('#') ;
+			if (ind != -1)
+				clean_window_location = loc.substring(0, ind) ;
+			
+			if (href.indexOf(clean_window_location) == -1q ) {
+				window.open(a.get("href"));
+				e.preventDefault(); ;
+			}
 		}
-
 	} ;
 
 	CY.all("#textcontainer a").on("click", interceptLink);