1. Advertising
    y u no do it?

    Advertising (learn more)

    Advertise virtually anything here, with CPM banner ads, CPM email ads and CPC contextual links. You can target relevant areas of the site and show ads based on geographical location of the user if you wish.

    Starts at just $1 per CPM or $0.10 per CPC.

innerHTML not working for Opera?

Discussion in 'JavaScript' started by YourChild, Feb 21, 2008.

  1. #1
    Hi,

    I am fairly new to javascript. my question might be elementary. here is the scenario:

    my html looks like this:

    <div id="dynamicTag"></div>

    <a href="#" onclick="loadText('encounter')">encounter</a>
    <a href="#" onclick="loadText('service')">service</a>
    ----------------------------------------------

    my javascript looks like this:

    function loadText(category){

    var newCategory = category;
    var myDiv = document.getElementById('dynamicTag');
    myDiv.innerHTML = newCategory;
    }


    looks simple right? I'm just changing the text inside of
    <div id="dynamicTag">

    Well on IE, Firefox, and Netscape it works fine.

    But it doesnt work right on Opera. The change takes place, but it would go back to default.

    So if I clicked the link, the text in the div is changed but the text disappears right aftewards...so the text blinks whenever I click. How do I fix this?

    Any help will be gladly appreciated. thanks!
     
    YourChild, Feb 21, 2008 IP
  2. zerxer

    zerxer Peon

    Messages:
    368
    Likes Received:
    18
    Best Answers:
    0
    Trophy Points:
    0
    #2
    Works perfectly fine in Opera for me. I went to a random website and right click > Source and I erased the entire page and simply put your coding in it and Applied Changes. When I clicked a link, it put the proper text there and kept it there.

    Code I put:
    
    <script>
    function loadText(category){
    
    var newCategory = category;
    var myDiv = document.getElementById('dynamicTag');
    myDiv.innerHTML = newCategory;
    }
    </script>
    <div id="dynamicTag"></div>
    
    <a href="#" onclick="loadText('encounter')">encounter</a>
    <a href="#" onclick="loadText('service')">service</a>
    HTML:
    Could you possibly link to the page you're doing this on so we can have a real test?
     
    zerxer, Feb 21, 2008 IP
  3. YourChild

    YourChild Peon

    Messages:
    22
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #3
    Thanks for the input. After a couple of hours of dabbling with it, I found out that I had an older version of Opera - 9.24

    I installed the latest - 9.26 and that solved the problem. wheww!
     
    YourChild, Feb 21, 2008 IP
  4. zerxer

    zerxer Peon

    Messages:
    368
    Likes Received:
    18
    Best Answers:
    0
    Trophy Points:
    0
    #4
    Odd that the version affected it. I'm still using 9.10. Perhaps it was a bad installation? Well, at least you got it working.
     
    zerxer, Feb 21, 2008 IP