dphg63476 2016-10-08 03:27
浏览 84
已采纳

如何在同一页面中打开网址,也可以使用javascript在新标签页中打开

it possible? how to do that? for now i just can open in same window

<div style='cursor: pointer;' onclick="window.open('dailyreport', '_self');">Daily Report</div>

that just for open in same window, if i change like this

<div style='cursor: pointer;' onclick="window.open('dailyreport', '_blank');">Daily Report</div>

open in newtab.

how to do if i want to open in same window, also can open in newtab if i want it? thanks

  • 写回答

3条回答 默认 最新

  • duaner5714 2016-10-08 03:47
    关注

    I hope I understand your question with this:

    <script type='text/javascript'>
        function Print_Report() {
            if(confirm("Do you want open on a new tab?") == true) {
                window.open('url.php', '_blank');
            } else {
                window.open('url.php', '_self');
            }
        }
    </script>
    
    <div style='cursor: pointer;' onclick='Print_Report();'>Daily Report</div>
    

    EDIT:

    Other possible option is create another div for that:

    <script type='text/javascript'>
        function Print_Report() {
            window.open('url.php', '_self');
        }
    
        function Print_ReportNewTab() {
            window.open('url.php', '_blank');
        }
    </script>
    
    <div style='cursor: pointer;' onclick='Print_Report();'>Daily Report</div>
    <div style='cursor: pointer;' onclick='Print_ReportNewTab();'>Daily Report</div>
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(2条)

报告相同问题?

悬赏问题

  • ¥15 java业务性能问题求解(sql,业务设计相关)
  • ¥15 52810 尾椎c三个a 写蓝牙地址
  • ¥15 elmos524.33 eeprom的读写问题
  • ¥15 使用Java milo连接Kepserver服务端报错?
  • ¥15 用ADS设计一款的射频功率放大器
  • ¥15 怎么求交点连线的理论解?
  • ¥20 软件开发方法学习来了
  • ¥15 微信小程序商城如何实现多商户收款 平台分润抽成
  • ¥15 HC32L176调试了一个通过TIMER5+DMA驱动WS2812B
  • ¥15 cocos的js代码调用wx.createUseInfoButton问题!