tags:

views:

48

answers:

4

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????

A: 

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.

RedFilter
A: 

Try evaluating this expression outside the write method.

Victor
did not get u...can u give me an example
Arun Abraham
A: 

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
kanaka
okie....thanks buddy...guess its the compiler issue in the backend of the platform that i was working on.....
Arun Abraham
A: 

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);
}
Victor