#1
  1. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Oct 2013
    Posts
    1
    Rep Power
    0

    Button working in Firefox and IE but not in Chrome or Opera


    I put up a temporary "test alert" which worked in Firefox. The following button worked in Firefox and IExplorer. But Chrome and Opera ignored my button (below).

    Code:
    alert('line 248'); // stops here okay.  No problem with either browser.
    
    //Below is the problem.
    // Chrome ignores this but Firefox recognizes it.
    
    document.getElementById('quiz_here').innerHTML='<button onclick="beginquiz();">GO AGAIN...</button>'; //whizzes right by this in Chrome but not in Firefox
    So I changed it to this:
    Code:
    var buttonmessage='<form> <input type="submit" name="submit" value="Go Again...bones" onclick="beginquiz()"/></form>';
    document.getElementById('quiz_here').innerHTML = buttonmessage;
    but the problem is the same. It also doesn't work in Opera.
  2. #2
  3. A Not To Shabby Code Smurf
    Devshed Beginner (1000 - 1499 posts)

    Join Date
    Aug 2008
    Posts
    1,165
    Rep Power
    184
    Try creating the button with DOM and see if the button is not created cross browser (it should be); the button should be created in all browsers (in theory). Here is an example, using your code:
    Code:
    function addForm()
    {
    var newButton = document.createElement("button");
    newButton.innerHTML = "GO AGAIN...";
     newButton.onclick = function(){
      beginquiz();
     }
    document.getElementById('quiz_here').innerHTML = ""; // clear div contents
    document.getElementById('quiz_here').appendChild(newButton);
    }
    Good Luck

IMN logo majestic logo threadwatch logo seochat tools logo