douzhi0107 2013-10-10 14:51
浏览 428
已采纳

如何在<a>标签中调用onclick函数?

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.

  • 写回答

4条回答 默认 最新

  • doulu2591 2013-10-10 14:54
    关注

    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')
    }
    

    See how to call it from your anchor tag

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

    Update

    Visit this jsbin

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

    May be this will help you a lot to understand your problem.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(3条)

报告相同问题?