Pentolan Pentolan - 1 month ago 7
PHP Question

how to open url in same page, and also can open in newtab using 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

Answer

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>
Comments