0

I am currently working on working on a platform where i can insert js code to be used is validated by some compiler and it returns errors for certain cases like

  1. document.write('<IMG ALT="" BORDER="0" NAME="DCSIMG" WIDTH="1" HEIGHT="1" SRC="'+dcsSrc+'">');

    error * :314:9:document.write can be a form of eval.

  2. parseInt function throws error if we do not use the optional radix parameter

Does someone know how the syntax or solution should be????

3
  • The problem seems to be that the platform you are using considers this kind of code to be an error. What platform are you using? Commented Oct 14, 2010 at 13:20
  • Are you wanting to write a validator that throws those errors you listed, or are you trying to figure out the syntax to get around those errors? Commented Oct 14, 2010 at 13:23
  • @Oded: i was trying to code in a platform that was built by another team, could not modify the platform, so was trying to figure out the syntax to get around these issues as 'kanaka' commented.. Commented Oct 18, 2010 at 13:25

5 Answers 5

1

These sound like JSLint errors messages. You should be able to configure what errors JSLint is checking for. See the Options section on this page, for more info on what options can be configured, e.g., tolerate eval.

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

Comments

1

Some Javascript implementations refuse to allow document.write because it can be an inherent security issue.

It's always important to use a radix with parseInt.

Here is an example:

parseInt("010");      // assumes base 8 because of leading zero
8
parseInt("010", 10);  // force base 10
10

1 Comment

okie....thanks buddy...guess its the compiler issue in the backend of the platform that i was working on.....
0

Try evaluating this expression outside the write method.

1 Comment

did not get u...can u give me an example
0

If the document.write is not working, you can try using:

function addElement(dcsSrc) {
  var parentNode = document.getElementById('parentNode');
  var newimg = document.createElement('img');
  newimg.setAttribute('src',dcsSrc);
  newimg.setAttribute('alt','');
  newimg.setAttribute('border','0');
  newimg.setAttribute('name','dcsimg');
  newimg.setAttribute('width','1');
  newimg.setAttribute('height','1');
  parentNode.appendChild(newdiv);
}

Comments

0

see:

http://www.jameswiseman.com/blog/2011/03/31/jslint-messages-document-write-can-be-a-form-of-eval/

solution:

document.write("?") -> document.body.innerHTML=?

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.