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条)

报告相同问题?

悬赏问题

  • ¥15 CVRP 图论 物流运输优化
  • ¥15 Tableau online 嵌入ppt失败
  • ¥100 支付宝网页转账系统不识别账号
  • ¥15 基于单片机的靶位控制系统
  • ¥15 真我手机蓝牙传输进度消息被关闭了,怎么打开?(关键词-消息通知)
  • ¥15 下图接收小电路,谁知道原理
  • ¥15 装 pytorch 的时候出了好多问题,遇到这种情况怎么处理?
  • ¥20 IOS游览器某宝手机网页版自动立即购买JavaScript脚本
  • ¥15 手机接入宽带网线,如何释放宽带全部速度
  • ¥30 关于#r语言#的问题:如何对R语言中mfgarch包中构建的garch-midas模型进行样本内长期波动率预测和样本外长期波动率预测