Is there any way to reverse preventDefaut() or return false?

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Brian Jacob
    New Member
    • Aug 2010
    • 1

    Is there any way to reverse preventDefaut() or return false?

    I am constructing a simple FAQ page, where the page loads with all of the available questions displayed and all answers are initially hidden.

    When the user clicks on a particular question, I am using javascript/JQuery to show the appropriate answer below that question. Due to differences b/n IE vs other browsers (FF, Safari), I had to use two different methods to show the answer, but I did get this to work in all cases.

    The sticking point comes when I want to use an answer to be able to link to another page to supply the details of that answer. Again, the non-IE browsers work - user clicks on a question, the "answer" is shown, and they can click on the shown link to redirect to the desired page. In IE however, the shown link does not work when clicked, but if you hover over it, the cursor behaves as if it is an active link and you can see the new page path displayed on the status bar. I believe the link does not work b/c IE thinks the preventDefault or return false; conditions are still in effect, even though those conditions are no longer true. see [CODE] below...

    Does anyone know if it is possible to "deactivate " a link in IE in order to show additional text, but then subsequently "reactivate " normal linking behavior once the hidden text has been displayed?

    Code:
    <script type="text/javascript">
    	var name = navigator.appName
     	if (name != "Microsoft Internet Explorer") {
    		$(document).ready(function() {
    			$(".faq_answer").hide();
    			$("#faqs li").toggle(
    				function() {
    					$(this).next(".faq_answer").show();
    				},
    				function() {
    					$(this).next(".faq_answer").hide()
    			}); // end toggle
    		}); // end ready
    	} else {	
    		$(document).ready(function() {
    			$(".faq_answer").hide();
      			$('#faqs li a').click(function(evt){
        				$(this).next('p').slideToggle(1);
        				return false; 
      			});
    			$("#faqs #faq_link").click(function(evt) {
    [B]				$(this).next('p a').open("http://www.nebraskaredzone.com/Banners/banners.html"); THIS CODE IS NOT WORKING[/B]
    			});
    		}); // end ready	
    	}; // end if
    </script>
    Last edited by Brian Jacob; Aug 9 '10, 07:03 PM. Reason: removing unnecessary comment
  • gits
    Recognized Expert Moderator Expert
    • May 2007
    • 5390

    #2
    i could think of a way to return false conditionally. you might set a flag (attribute) to the node and set its value to false initially. when the first action occurs the flag is false and you might return false ... then set that flag's value to true and return true when the next click occurs. that way you simply might return the flag's value.

    kind regards

    Comment

    Working...