1. ホーム
  2. javascript

[解決済み] how to call a onclick function in <a> tag?

2022-03-05 15:19:17

Question

i want to open a new window on click of 1

$leadID = "<a href='javascript:onclick=window.open(lead_data.php?leadid=1, myWin, scrollbars=yes, width=400, height=650);'>1</a>";

it is not showing me error. is there any other way to open new window.

here is the fiddle http://jsfiddle.net/ankurdhanuka/uwypv/

Thanks in advance.

How to solved?

Try onclick function separately it can give you access to execute your function which can be used to open up a new window, for this purpose you first need to create a javascript function there you can define it and in your anchor tag you just need to call your function.

Example:

function newwin() {              
 myWindow=window.open('lead_data.php?leadid=1','myWin','width=400,height=650')
}

アンカータグから呼び出す方法を見る

<a onclick='newwin()'>Anchor</a>


更新情報

このjsbinにアクセスする

http://jsbin.com/icUTUjI/1/edit

これは、あなたの問題を理解するのに非常に役立つかもしれません。