开发者

Annoying this.refresh() is not a function in Firefox

Here is the solution to my problem. I am able to make a field appear, enter a new value, click the field again and make the field disappear with the new value. The Firefox error console complains every time that this.refresh() is not a function.

How do I get rid of the this.refresh() is not a function error so that I can clear my Firefox console and look for errors that act开发者_开发技巧ually cause problems?

var gotIt='no'

function askName(x)
 {if(gotIt=='yes')
   {response=this.name
    characters[x].setName(response)
    gotIt='no'
   }
  else
   {gotIt='no'
    this.name=characters[x].name
    response="<input onClick=_setName(this.value) size=10 type=text value="+this.name+">"
    characters[x].setName(response)
   }
 }
function _setName(x)
 {this.name=x
  this.refresh()
  gotIt='yes'
 }


Almost everything in your code is wrong, the following code do what you need. If you want to understand javascript you need to strive.

Annoying this.refresh() is not a function in Firefox

<!doctype html>

<html>
    <head>
        <script>
            window.onload = function () {
                var input = document.createElement ("input");
                var span = document.getElementsByTagName ("span")[0];

                input.addEventListener ("blur", function () {
                    span.innerHTML = this.value;
                }, false);

                span.addEventListener ("click", function () {
                    if (this.getElementsByTagName ("input").length === 0) {
                        input.value = this.textContent;

                        this.innerHTML = "";

                        this.appendChild (input);

                        input.focus ();
                    }
                }, false);
            }
        </script>

        <style>
            span {
                font-weight: bold;
            }
        </style>

        <title></title>
    </head>

    <body>
        <span>Braveheart</span>
    </body>
</html>
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜