2

So here is the problem. There is a HTML/JS code, but I can't read v3 variable. In short anything after DDDD(D,{"COM":"lng","leaf":145,"AXIS":true}); (which is some kind of predefined random array) is unreadable(or ignored as JS code). Why? And how can i get contents of v3? Is this a javascript parse bug?

<html>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<head>
<script type="text/javascript">
  <!--
  var v1 = 12345;
  var v2 = "Hello world";
  DDDD(D,{"COM":"lng","leaf":145,"AXIS":true});
        var v3 = "World Hello!!!"; 
  //-->
</script>
</head>

<!-- some html code -->
<script>

alert("This is "+v3);

</script>

<!-- some html code -->
</html>
2
  • Where DDDD is defined? Do you have it in some other file that's loaded before this particular snippet? Commented Jan 2, 2011 at 13:29
  • "which is some kind of predefined random array" - I think you just forgot to include this predefined stuff. :) Commented Jan 2, 2011 at 13:33

6 Answers 6

4

Your first script crashes because you don't have a DDDD function, so the v3 never gets assigned.

You refer to the DDDD line as "which is some kind of predefined random array". It's not.

It is an attempt to call a function, and pass it two arguments.

  • DDDD() a function call.

  • a D variable argument.

  • a {"COM":"lng","leaf":145,"AXIS":true} object literal argument.

Sign up to request clarification or add additional context in comments.

1 Comment

It's ok guy's, i just realise i forgot to include some remote script src. Thanks :)
1

I assume that D and DDDD are defined somewhere? Your code excerpt doesn't define them. If they're defined, I'm not seeing the error; if they aren't, well, that's your problem.

Comments

1

Your problem is that the DDDD() line throws an exception because it uses an undefined function (DDDD is not defined), then anything that follows inside that script tag is not executed. The second script tag is executed however, but it doesn't have access to the variable that was never defined.

Comments

1

You can catch errors and then v3 will come out fine:

<script type="text/javascript">
      <!--
      var v1 = 12345;
      var v2 = "Hello world";
      try {
         DDDD(D,{"COM":"lng","leaf":145,"AXIS":true});
      }
      catch (ex) {
         alert("error: " + ex.message);
      }
      var v3 = "World Hello!!!"; 
      alert(v3);
      //-->

</script>

Comments

0

There is an error at line

DDDD(D,{"COM":"lng","leaf":145,"AXIS":true});

When an error occurs. Remaining JS is not executed.

Comments

0

When javascript gets an error in a line (depends the egine) it either breaks or fails to load entirely. And like most people already said before me, the DDDD() has to exist somewhere else is undefined.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.