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 7418731
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 29, 20262026-05-29T07:56:17+00:00 2026-05-29T07:56:17+00:00

I am using CSS to apply a background image to a div tag that

  • 0

I am using CSS to apply a background image to a div tag that wraps all of the content on a website.

<div id="mainBack">
  <%-- All other content goes here --%>
</div>

And the CSS id with the background property…

#mainBack
{
    background: url(../images/background.jpg) repeat-x top;
    padding: 15px 0 20px 0;
}

PROBLEM:
I’m trying to figure out how to open a new browser window to a different URL whenever the background image is clicked upon. I have tried doing this using jQuery, but the manner in which I implemented it actually causes every click on anything in the website to open a new window. The jQuery click event that does this – although incorrectly – is below:

$('#mainBack').click(function () {
    window.open('http://InternalBusProcess:8083/HyperFix.jpg', 'HyperFix');
});

Any suggestions on how I can go about implementing this behavior in a fashion that actually works?

  • 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-29T07:56:18+00:00Added an answer on May 29, 2026 at 7:56 am

    You can stop the propagation of click events for elements on top of your #mainBack element.

    For example:

    <div id="mainBack">
        <a href="#">Some Link</a>
    </div>
    
    <script>
    $('a').on('click', function (event) {
        event.stopPropagation();
    });
    </script>
    

    This will make it so any link clicked on will not allow the event to bubble up to any ancestor elements. Which in turn will make detecting a click on the #mainBack element possible.

    You will have to stop the propagation of the event on any element you want to be clickable without opening the popup window.

    Also, note that .on() is new in jQuery 1.7 so if you’re using an older version, change .on() to .bind().

    Update

    You can also use the event object inside your event handler to check if the targeted element is the #mainBack element:

    $('#mainBack').click(function (event) {
        if (event.target.id == 'mainBack') {
            window.open('http://InternalBusProcess:8083/HyperFix.jpg', 'HyperFix');
        }
    });
    

    Here is a demo of using event.target: http://jsfiddle.net/j5NuW/ (notice the event handler is attached to the body element but the alert only shows if you click the #mainBack element)

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

Sidebar

Related Questions

Using CSS, when a link is clicked it brings up a hidden DIV that
I have an element on a page with background image set using css: //
CSS & html id0 is the class for the div that's got background as
I have been using the following CSS to apply an effect at the bottom
Using CSS, I'm trying to specify the height of a span tag in Firefox,
I am using CSS Tidy. Due to all of its compression measures, in some
I have been debating using css with div's and laying out elements, and really
I'm having a problem using CSS's display:inline property with the list-style-image: property on <li>
I am having an issue applying css dynamically to a loaded div using the
I am using the webbrowser control in winforms and discovered now that background images

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.