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

报告相同问题?

悬赏问题

  • ¥50 求图像处理的matlab方案
  • ¥50 winform中使用edge的Kiosk模式
  • ¥15 关于#python#的问题:功能监听网页
  • ¥15 怎么让wx群机器人发送音乐
  • ¥15 fesafe材料库问题
  • ¥35 beats蓝牙耳机怎么查看日志
  • ¥15 Fluent齿轮搅油
  • ¥15 八爪鱼爬数据为什么自己停了
  • ¥15 交替优化波束形成和ris反射角使保密速率最大化
  • ¥15 树莓派与pix飞控通信