neo neo - 1 year ago 58
HTML Question

Why can't browser render this simple javascript code?

I was trying to show a simple image in the browser with this piece of code.But it shows error saying:

403 error forbidden.

On more evaluation I found out that the http request sent was sent in the form


which is my local webserver address. Is this a cross-site scripting issue ?

function onclickfunction(){
var a = document.createElement('img');
a.src ='""';
<button onclick= "onclickfunction();"> Click Me!</button>

Answer Source

Try removing the enclosing single quotes from the URL:

a.src ="";
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download