jquery - How does this link execute javascript -


i trying reverse engineer web page sorta. have access source code thousands of files looking find way narrow down search want.

the page has image words new. when click client side action executes. client side because monitoring fiddler not show server request.

anyway javascript function executes.

what trying locate script executes. using f12 developer tool went inspect element clicked and...i stopped dead in tracks.

<a href="javascript:void(0);" title="create" tabindex="0" class="classname">     <img src="/_imgs/add_10.png" class="pictureclass">new</a> 

how javascript:void(0) execute script? perhaps i'm wrong , making server postback??

any pointers appreciated.


as update pointers have been quite helpful still can't find event being fired....but partially due having focus on couple other issues.

one thing has cause me difficulty there running script when pause execution @hafthor states chrome dev tools put blue modal on page , can't click controls.

the void(0) "do nothing" construct , javascript: protocol should avoided since recommended use click event handler , return false or cancel event preventdefault

the void means "return nothing" , if not in javascript protocol, run risk call returns value shown in page.

example (that served better unobtrusive js, shown example)

<a href="javascript:window.open('somepage.html','_blank')">click</a> 

will pop window if allowed render

[object object] 

in page link.

<a href="javascript:void(window.open('somepage.html','_blank'))">click</a> 

will not since void suppress return value of window.open , in effect similar

<a href="#" onclick="window.open('somepage.html','_blank'); return false">click</a> 

again not recommended have inline event handlers.

the script saw execute still added externally link

window.onload=function() {   document.getelementsbyclassname("classname")[0].onclick=function() {     newimage();   } } 

which not hindered void(0)

a better alternative be

window.onload=function() {   document.getelementsbyclassname("classname")[0].onclick=function() {     newimage();     return false; // javascript:void(0) can removed link   } } 

Comments

Popular posts from this blog

php - SPIP: From Tag directly to an article -

jquery - isAjaxRequest always return false -

ruby on rails - In a controller spec, how to find a specific tag in the generated view? -