Elm open url in a new tab - elm

I am trying to learn Elm and trying to figure how to open a url in a new tab instead of the same page.
The following piece of code opens the URL in same page:
Browser.Navigation.load (url)
what do I need to replace this with so this URL opens in a new tab?

You should be able to easily do this with ports.
port module Main exposing (main)
port newTab : String -> Cmd msg
and in JS
app.ports.newTab.subscribe( url => window.open(url, '_blank'));
[2021-02-22] edit:
The above solution assumes that the programmer wants to open an url programmatically (from the update function) and that Html.target_ "_blank" was not an option.

An Elm app doesn’t manage your browser tabs, just the one tab in which it is currently running (neither does a JS app, by the way!).
So the Browser.Navigation API is of no use here, you must simply use a plain HTML a with target="_blank", as #viam0zah commented:
Html.a [ Html.Attributes.target "_blank"] [ Html.text "Open in a new tab" ]

Related

Nuxt: How to open page in a new tab

I go through the documentation of Nuxt, but couldn't find information about how to open a page in a new tab. Is there a way to open a link in a new tab instead of opening it in the current tab? I tried the following code:
<nuxt-link to="/user" target="_blank">User</nuxt-link>
But it doesn't work.
The whole point of vue-router is navigating inside a single page application so it doesn't have a way to navigate to a blank new tab as far as I know. Fortunately there is an old fashioned thing called 'html' which has something called an anchor tag that you can use like this:
User
As #anthonygore pointed out in a comment to first post.
It's now working to open link in a new tab by , having all the features of router name/path link
do it with by adding target="_blank" to/inside NuxtLink to have
<NuxtLink :to="..." target="_blank">Nuxt link to external page</NuxtLink>
or just use default
A link to external page

How to handle new tab opening with Splash?

I'm scraping website which has a very annoying link (<a> HTML tag) - it opens the small pop-up form on click and after submitting it, opens new browser tab (and switches focus to it) with URL that I need, and also redirects old tab to another page.
Successful submitting of the pop-up form was easy, but I don't know how to get URL of this new tab.
And as the documentation says, Splash can work only with one tab, so is it impossible to do that?
As Splash's developer comments on this GitHub issue this feature is not implemented.
But I posted my solution to this problem on the same issue.
Example:
function main(splash, args)
assert(splash:go(args.url)) -- execute JS code below only after loading the page
splash:runjs("var newTabURL")
splash:runjs("newTabURL = null") -- sometimes JS can't find variable without this line
splash:runjs("window.open = function(url){newTabURL = url}")
-- actions which open the new tab
local new_tab_url = splash:evaljs("newTabURL")
-- other actions
end

Open Asp.net MVC View page in a Tab

how can i open an asp.net MVC view page in new tab. I have a left panel from where you will redirect to new page and i need to open that page in new tab of existing project not in new window.And also from ExtJS Sencha grid cell click.
Isn't it the anchor attribute target http://www.w3schools.com/tags/tag_a.asp what you are looking for? If yes then look here Opening a link in a new tab for the details how to use it.
You can't to this in a standard way.
Opening pages in new tab or new window, is a browser configurable option, not a programmable manner. So, you haven't any control over it.
However, opening new pages(whether in new tabs or new pages) is achieved in client side by this javascript line:
window.open();
Now, you have two ways in front:
1) You just want to open a new tab/page and request a view. Just set the url in the open() method:
window.open('#Url.Action(...)');
2) You send some data to controller and want to show the results in new tab/page.
First, send an ajax or ordinary post request to the controller and retrieve results in the same view.
Then, open a new tab/page and put that result to it:
var w = window.open();
$(w.document.body).html(content.responseText);

Chrome extensions: How can I pass form variables to a url in a newly created tab?

I'm working on my first chrome extension, and using an image-based context menu item to capture the URL of a given image, and want to then display that image at a specific URL in a new tab. So, I need to pass the URL of the image clicked on (using srcUrl) to a specific script that can then render it on that page. Is it possible to perform an HMLHttpRequest from within a chrome.tabs.create() call, or must this be done some other way?
Thanks for any help.
You would need to create an HTML page containing that script and put it into your extension folder. Then you can just pass image url to it as GET parameter:
chrome.tabs.create({url: "local.html?img_url=...");
If url parameter is not enough, you would be also able to communicate with that page using chrome.tabs.sendRequest():
chrome.tabs.create({url: "local.html", function(tab){
chrome.tabs.sendRequest(tab.id, {img_url: "local.html?img_url=...");
));
With the request listener in that page:
chrome.extension.onRequest.addListener(function(request) {
console.log(request.img_url);
});

Selenium Address Bar

Good morning
I am using selenium and I have come up against a bit of a wall.
I am attempting to navigate to another page, by typing in the address bar, however I cant seem to do this when using selenium.
Is this possible?
I am not able to simply put a link on the page that goes to this page.
Cheers Cameron
Short answer: Try the "open" command.
Long answer: Selenium doesn't support "typing in the address bar". It can only control what is IN the page canvas, or more specifically, it can only do what JavaScript can do. In other words, it can change the location, but not by actually typing something in to the address bar. The open command uses JavaScript to change the page's location.
The address bar is where you put the base url,
and to use the open the url you need to use the selenium open command,
EX:
Base URL: google.com
command1#
command = open
target = /