trying to open a new tab in the browser |
I am trying to open a new tab in the browser. I tried using the code below directly in the controller but I am getting a message "popup blocked". I really don't want a popup. I just want to open another tab that is set to https://patents.google.com/.
echo '<script type="text/javascript"> window.open("https://patents.google.com/"); </script>'; Anyone know how to accomplish this?
proof that an old dog can learn new tricks
where is the function that will trigger the JS ?
I think it should be like this Code: <!DOCTYPE html> here the openTab() function will trigger whats inside it when called via the onclick attribute. You just echoed the window.open line , i dont think this will work. Increase Your Awareness
I was wrong regarding that you should use a function to execute this line
window.open('https://duckduckgo.com/?t=ffab', '_blank'); i tried it directly in the controller and it worked <?php namespace App\Controllers; use CodeIgniter\Controller; class Controller1 extends Controller { public function index() { echo " <script> window.open('https://duckduckgo.com/?t=ffab', '_blank'); </script> "; } } but firefox told me that its preventing popups , so i enabled them for localhost , maybe you are disabling them. Increase Your Awareness
(07-18-2020, 03:01 PM)BlackBanana Wrote: I was wrong regarding that you should use a function to execute this line Worked great. thanks.
proof that an old dog can learn new tricks
Well I decided that I want to give the user control over opening the window. I have added this button to my screen;
<div style=”float:left”> <button onclick="document.location='\'https://patents.google.com/\''">Open Google Patents</button> </div> But clicking this causes this path to open: http://localhost/index.php/Configure/'ht...oogle.com/' when I really want just https://patents.google.com
proof that an old dog can learn new tricks
Code: <button class="btn btn-primary btn-lg" onclick="location.href='https://patents.google.com/'">Open Google Patents</button> What did you Try? What did you Get? What did you Expect?
Joined CodeIgniter Community 2009. ( Skype: insitfx )
thx. That worked. One thing, I'd like to open Google Patents in a new tab. How can I change that?
I tried this mod <button class="btn btn-primary btn-lg" onclick="location.href='https://patents.google.com/','_blank'">Open Google Patents</button> but it still opens in the same tab
proof that an old dog can learn new tricks
Add this to it:
Code: target="_blank" What did you Try? What did you Get? What did you Expect?
Joined CodeIgniter Community 2009. ( Skype: insitfx )
I am getting the same thing:
<div style=”float:left”> <button class="btn btn-primary btn-lg" onclick="location.href='https://patents.google.com/',target='_blank'">Open Google Patents</button> </div>
proof that an old dog can learn new tricks
|
Welcome Guest, Not a member yet? Register Sign In |