Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6749805
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T12:44:01+00:00 2026-05-26T12:44:01+00:00

I have some JS on my site that should prevent the following code from

  • 0

I have some JS on my site that should prevent the following code from reloading the page (as I use AJAX to refresh part of it), but in IE it is always reloading the page. Every other browser is fine.

The JS, as givein in another thread –

$('#attachment-body').delegate("a", "click", function(e){
    e.preventDefault();
});

The links that are still reloading the page (which is within the #attachment-body container) –

<div id="image-navigation">
    <div id="nav-previous" class="nav-previous attachment-nav-previous float-left">
        <p><a id="previous-link" href="<?php echo get_permalink($attachments[$previous_position]->ID); ?>" title="<?php echo esc_attr(get_the_title($attachments[$previous_position]->post_title)); ?>" onclick="set_centre_image(<?php echo $attachments[$previous_position]->ID; ?>, <?php echo $previous_position; ?>)">&laquo; Previous Image</a></p>
    </div>
    <div id="nav-next" class="nav-next attachment-nav-next float-right">
        <p><a id="next-link" href="<?php echo get_permalink($attachments[$next_position]->ID); ?>" title="<?php echo esc_attr(get_the_title($attachments[$next_position]->post_title)); ?>" onclick="set_centre_image(<?php echo $attachments[$next_position]->ID; ?>, <?php echo $next_position; ?>)">Next Image &raquo;</a></p>
    </div>
</div>

When rendered it this is the block of code generated by the above –

<div id="image-navigation">
    <div id="nav-previous" class="nav-previous attachment-nav-previous float-left">
        <p><a id="previous-link" href="http://mydomain.com/firm-news/summer-drinks-at-the-castle/summer-drinks-2011-6/" title="" onclick="set_centre_image(5144, 5)">&laquo; Previous Image</a></p>
    </div>
    <div id="nav-next" class="nav-next attachment-nav-next float-right">
        <p><a id="next-link" href="http://mydomain.com/firm-news/summer-drinks-at-the-castle/summer-drinks-2011-8/" title="" onclick="set_centre_image(5146, 7)">Next Image &raquo;</a></p>
    </div>
</div>

preventDefault() works in IE as I use it in other areas of the site, so I can only think that something in my code is not right.

Thanks.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-26T12:44:02+00:00Added an answer on May 26, 2026 at 12:44 pm

    I think I’ve solved this now…

    When a next/previous link in my gallery was clicked, it fired a JS function (using onClick()) that first cleared the div that I ran the preventDefault() agianst. Instead of that, I hid it and it now works.

    I’m no expert, but it looks like IE tests for the .delegate(), .live() and click() methods after it fires the function specified inline (meaning that #attachment-body didn’t exist at the point it was checking for it), where as other browsers do it the other way around.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have some code on my PHP powered site that creates a random hash
I have to call some code in a SharePoint site that runs under the
I have some code that creates a new site in SharePoint. Upon browsing to
I have some code that sets the lang var to the site default language.
I have some pages on my site that are plain HTML pages, but I
We will develop a web site that will have some free services and we
We have a site that is serving some RSS feeds, and we'd like to
I have a site that features some pages which do not require any post-back
Due to a prinitng error in some promotional material I have a site that
Argghh. I have a site that offers audio previews of songs hosted elsewhere. Some

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.