onclick in DIV tag not working in Mozilla and older verisons of IE

I have some code where there is a onclick event in a DIV tag. It works in new version of IE but not in IE 7 & 8 and Mozilla. Anyone know why this isn't working?

Code:
            <div class="program" style="cursor:pointer;" onclick="window.location('GBR.aspx');">
                <div class="programImage"><img src="images/Programs1.gif" style="border:0" alt="AltImage" /></div>
                <div class="programInfo">
                    <div class="programTitle">Heading Text Here</div>
                    <div class="programLine"></div>
                    <div class="programDesc">Text here</div>
                </div>
            </div>
vb9666Asked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

APoPhySptCommented:
hi,

A better option, especially since you are using jQuery, is to not use inline event handlers.

Instead, use this HTML:

<div class="program" style="cursor:pointer;" >

<script>
$(document).ready(function () {
    $(".program").on("click", function () {
        window.location('GBR.aspx');
    });
});

</script>

Open in new window

0
APoPhySptCommented:
in the example I posted before the javascript must come after the div, but if you want to centralize the javascript on the top of the page os something like that you can put the '<script>' tags at the top with the following modification:

<script>

$(function() {

    $(document).ready(function () {
        $(".program").on("click", function () {
            window.location('GBR.aspx');
        });
    });

});

</script>

Open in new window


this tells the page to execute this function only after all the html has been loaded.
0
vb9666Author Commented:
I don't see how the script is calling the function on the onclick event?
0
Cloud Class® Course: Microsoft Windows 7 Basic

This introductory course to Windows 7 environment will teach you about working with the Windows operating system. You will learn about basic functions including start menu; the desktop; managing files, folders, and libraries.

vb9666Author Commented:
I tried this with javascript and calling a function and it does not work in Mozilla.

<div class="program" style="cursor:pointer;" onclick="javascript:OpenGBR();">
                <div class="programImage"><img src="images/Programs1.gif" style="border:0" alt="AltImage" /></div>
                <div class="programInfo">
                    <div class="programTitle">Heading Text Here</div>
                    <div class="programLine"></div>
                    <div class="programDesc">Text here</div>
                </div>
            </div>

    <script type="text/javascript" language="javascript">
        function OpenGBR()
        {
            window.location('GBR.aspx');
        }
    </script>
0
vb9666Author Commented:
I think the issue has something to do with the window.location. It works fine in IE but not Mozilla. If I change the code to window.open then it works in both browsers but I don't want to open a new window.
0
APoPhySptCommented:
then, instead try it with:

window.location.href = GBR.aspx

Open in new window

0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
ASP.NET

From novice to tech pro — start learning today.