neo neo - 7 months ago 32
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>


Try removing the enclosing single quotes from the URL:

a.src ="";