onclick works in FF but not in IE7

Discussion in 'Javascript' started by sisqorap, Feb 20, 2008.

  1. sisqorap

    sisqorap Guest

    Hi all,

    I have a problem with a dynamic made onclick and I'm trying to figure
    it out with a little page but I can't get it to work in IE7. Can
    somebody help me out?

    This is the code:
    <script language="Javascript" type="text/javascript">
    function Loading(){
    <body onLoad='javascript:Loading();'>
    <div id='hallo'>HAAALLOOO</div>

    sisqorap, Feb 20, 2008
    1. Advertisements

  2. sisqorap

    David Mark Guest

    Add a doctype.
    Lose the language attribute.
    The get/setAttribute methods are broken as designed in IE. Set the
    onclick property to an anonymous function instead.
    Lose the "javascript:" prefix.

    David Mark, Feb 20, 2008
    1. Advertisements

  3. sisqorap

    sisqorap Guest

    What do you mean with this one?
    I've did all the rest except for the anonymous function and it didn't
    work yet on IE
    sisqorap, Feb 20, 2008
  4. sisqorap

    David Mark Guest

    var el = document.getElementById('hallo');
    if (el) {
    el.onclick = function() {

    David Mark, Feb 20, 2008
  5. sisqorap

    sisqorap Guest

    Ok thx this works fine!

    Thx for the quick replys
    sisqorap, Feb 20, 2008
    1. Advertisements

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments (here). After that, you can post your question and our members will help you out.