0

I have a simple jquery code that work's fine, but not in IE8.

I have a button with onclick="unlock();". The unlock() function is in external file named js/unlock.js.

In the IE8 debugger tool it marks all of the function and write this error:

Object Doesn't Support This Property or Method (Line 1 Char 1) 

The website is not writen in English, but please check this out. The unlock button looks like this: enter image description here
(source: gyazo.com)

Link to the website: http://www.nitrobit.net/view/RDIWVmLAJ BTW: You need to write something in the input next to the button.

What is wrong?

The JS code: (unlock.js):

unlock = function() { var password = $("input[name='password']").val(); if($.trim(password).length != 0) { locked_div = $("#locked_div").html(); $.ajax({ url: 'ajax/unlock.php', type: 'post', data: { password: password, file: $("input[name='fileId']").val(), keep: ($("input[name='keep']").is(':checked')) ? 'true' : 'false' }, beforeSend: function() { $("#locked_div").html('<img src="img/ajax-loader.gif" alt="loading" />'); }, success: function(data) { if(data.indexOf(0) == 0) { data = data.slice(1); $("#locked_div").html(locked_div); $("#error").html(data); } else { $("#locked_content").slideUp(); $("#prem_message").slideUp(function() { $("#dl_section").html(data); $("#download").fadeIn('slow'); }); } } }); } } 

Thanks, and sorry for my English

5
  • 3
    Always include the relevant code in the question itself, don't just link. In particular, we'd have to see where and how unlock is defined. (If it's defined within a scoping function, for instance, then it's not a global and isn't available from an onclick="..."-style handler.) Commented Oct 11, 2013 at 10:21
  • @insertusernamehere that would definitely be the problem. Commented Oct 11, 2013 at 10:24
  • @insertusernamehere there is <base href="http://www.nitrobit.net/" /> Commented Oct 11, 2013 at 10:24
  • @T.J.Crowder Sorry, I updated the question and puted the code Commented Oct 11, 2013 at 10:26
  • @insertusernamehere Yes. the error is like I said Object Doesn't Support This Property or Method (Line 1 Char 1) And there are no other errors. Commented Oct 11, 2013 at 10:27

1 Answer 1

2

When testing your code in Internet Explorer 8 I get a slightly different position of the error:

unlock.js, line 4, char 9

It's this line:

locked_div = $("#locked_div").html(); 

When looking for IE8 and .html() on Google you'll find lots of cases, where the .html()-method fails in reading or writing. You also use an outdated version of jQuery (1.7).

I would suggest:

  • update to jQuery 1.10.x
  • if the problem persists, try to use plain JavaScript functionality instead
  • or alternatively: clone the node instead of reading it's content
Sign up to request clarification or add additional context in comments.

3 Comments

What's the meaning of "clone the node " ?
If I got yor right, you're trying to store the node value for later. You could also clone() (duplicate) the whole node and then replace it. Or you could grab all children() and replace the content later on. Both are alternatives to not use html().
Thanks!!! I removed this variable and replaced it with something else, and now it works! Thank You

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.