简体   繁体   中英

Empty Onclick and href in Anchor tag

I have two questions.

1) when I click on a link, I got an html page as response. Looking at the page source I can see CASE 1 but when I inspect element i see CASE 2

I dont understand why this happens. Can someone tell me what could be the reason ?

2) when I click on the refresh icon ( which is created by the code above), i am not redirected to link mentioned in href. Since href is blank and so is onclick function, I wonder what happens?

Actually i am redirected to link http://localhost:8080/drm/actions/scm/deploy-manager/filter?filter_preserve=true

I know that if href is blank i shall be redirected to same page. I know that If onclick function returns false the default browser behaviour is cancelled. But what will happen in my case ? Is my onclick function actually blank ? When I put a breakpoint on addCheckBoxValuestoURL(this.href,'null') function, is does not stop.

CASE 1 ( page source )

<a href="/drm/actions/scm/deploy-manager/show? table_name=deployed_packages&filter_preserve=true"
onclick="addCheckBoxValuestoURL(this.href,'null');return false;"><img src="/images/icon_refresh.png" width="16" height="16" border="0" alt="Refresh" title="Refresh" /></a>

CASE 2 ( when I inspect element in chrome)

<a href="" onclick=""><img src="/images/icon_refresh.png" width="16" height="16" border="0" alt="Refresh" title="Refresh"></a>

The refresh button should redirect it to same page but this functionality is not working.

I dont understand why this happens. Can someone tell me what could be the reason ?

The browser generates a DOM from the source code, then JavaScript modifies the DOM.

Since href is blank and so is onclick function, I wonder what happens?

There must be an event handler in the page which is not bound to the element using the onclick attribute.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM