useNavigate: Navigate to external Link - react-router-dom

on Clicking of a button, I want to perform an async operation and after that navigate user to an external website as shown below:
navigate("https://wwww.google.com?q=ABC")
But here's the problem:
while using navigate, my url changes like this, because for some reason it's assuming relative path:
http://localhost:3000/https://wwww.google.com?q=ABC
Can someone help me understand what is going wrong? I also tried setting replace to true but no luck there as well.

window.location.href = "https://wwww.google.com?q=ABC";

Related

How to redirect to a website in Godot Web

I'm planning on trying to see if it's possible to make a website in Godot(Yes, I know I shouldn't I just want to try just to try). I thinking about and looking over the features I need and I have one problem.
I just need a way for a person to press a button and get redirected to my itch games. I don't care if it creates a new tab or changes the current tab. Thank you for any help.
If you dont export to web you can call
OS.shell_open("url")
Sadly this does not work in an html export. A solution I found for myself is the JavaScript Interface. As the name suggested it allows you to execute Javascript.
So to open a URL you could connect the pressed signal of a button to something like this:
if OS.has_feature('JavaScript'):
JavaScript.eval("""
window.open('https://google.com', '_blank').focus();
""")
This will open a new tab in the active browser.
I also found an article on the godot site, basically asking the same question (https://godotengine.org/qa/46978/how-do-i-open-richtextlabel-bbcode-links-in-an-html5-export). Here they tried to use an RichTextLabel with BBCode.
The solution did not work for me, when I tested it, though.
As pointed in the comments you can try OS.shell_open, for example:
OS.shell_open("https://example.com")
That only works if it is not an HTML export.
Your other alternative is to eval JavaScript, for example this navigates the current tab:
JavaScript.eval("window.location.href='https://example.com'")
Which only works if it is an HTML export.
Since that only works for an HTML export and the other does not work on an HTML export... If you need both you can do this:
if OS.get_name() == "HTML5":
JavaScript.eval("window.location.href='https://example.com'")
else:
OS.shell_open("https://example.com")
See also Close a game in Godot.

Get Tabs URL, copy to new tab, change something in domain

Basically I just want to check links across different environments and thats just a different domain name. So basically I have my extension so far with buttons for each one but am having trouble getting anything to happen. Tried in b ackground.js as I thought that was the only place to access tab?
Tried this and some other variations but yeah this is very new to me so forgive my ignorance. I know javascript well enough but this is taking a bit to adjust.
let dev = document.getElementByID("dev");
console.log(dev);
dev.onclick = function(element) {
chrome.tabs.query({currentWindow: true, active: true}, function (tab) {
chrome.tabs.update(tab.id, {url: "www.google.com"});
});
1) An URL must start with a scheme: https://www.google.com. 2) Make sure to read about the extensions overview::architecture - the popup is a separate page with its own window, URL, and devtools which you can access by rightclicking the popup, then clicking Inspect. 3) Hint: no need to use tabs.query to change the active tab - simply omit tab.id, from tabs.update as it's an optional parameter. – wOxxOm
Thanks that helped a lot!

Can I use .htaccess for redirects?

I am using coppermine gallery, the only suggestion so far, on their help forum, was to inquire with stackoverflow. Problem - when you click on one of the Categories on main page It goes to "No image to Display". I would like it to go to something like "You must be logged in to view these pages" or something like that. The coppermine forum suggested maybe redirects in an .htaccess file? Is that the best way? I think the easiest way to explain is this: When you Click on Coudy here:http://stalag13000.net/Gallery/index.php it goes to "No image to display" but I would like it to at least go to here:http://stalag13000.net/Gallery/login.php?referer=index.php%3Fcat%3D2
I did see some posts on .htaccess but I am far from knowing if any of that could or would apply to my scenario,
Thanks for any help or direction,
yamiacaveman
If you are going to display info only to people who are logged in, you would check in the
$_ SESSION
variable to see if they are logged in or not. If they are not, you would then direct them with php to the login page.
header('Location: /login.php');
header location with php
I like Ollie Ford's suggestion. You could open a modal over the current screen, ask for them to login there and then, on success, you could thank them, close the modal, and show the content on the page.

MODX: I added a resource page and now all my links are broken

A client wanted me to add a page to his Modx website. I am only a Joomla/Wordpress guy but I figured I would take a stab at it.
Here were my steps:
I clicked "new document", gave the page a template, a name, a parent, then pasted in some dummy text and hit save.
Now, all of my links look like this: http://www.myurl.com/modx/contact.html
edit: Actually that is how they are supposed to look according to google. They just simply are not linking to the page any longer.
My blog link still looks like this: http://www.myurl.com/blog (and it is the only link on the page that works)
I cannot delete the resource that I created under any circumstances. Modx just crosses it out in red and there is no option to permanently delete it, that I can find.
edit: Got that part solved... :)
Thanks for your help, I am trying to fix this before the client realizes it is broken.
You specified base tag in head? Like this: <base href="http://www.myurl.com/modx/" >.
And to fully remove the resource you need to press the trash icon on top resource panel tree.
Getting rid of the resource group assignments sorted out the issue, and the site is now fully accessible again.

Chrome extension: Copy text

I have a simple chrome extension where I'd like to click an image and copy the href of the link next to it. I have everything in place, but the copy will not work for the life of me. I have the following premissions in my manifest:
"permissions": [
"clipboardRead",
"clipboardWrite"
]
I then create an input with id "copyInp" and use the following function to copy to clipboard (tried to be as deliberate as possible here, so it's not the most compact):
function copyLinkToClipboard( link ) {
$("#copyInp").val(link);
var inp = document.getElementById("copyInp");
inp.focus();
inp.select();
document.execCommand('copy');
};
After this runs, I get nothing new in my clipboard when I ctrl+v. Any ideas as to what's going wrong here? The input definitely has the text I want in it, and I have the permission in the manifest. Any help would be greatly appreciated...
After a bit more digging I discovered I needed to use a background page. Apparently this is the only thing you can call document.execCommand on. So the fix is to create a background.html with the copy function and the input in it, add a listener like so:
chrome.extension.onRequest.addListener(function(obj) {
copyLinkToClipboard( obj.link );
});
and then use sendRequest to pass the text you want copied to the background page:
chrome.extension.sendRequest({link: linkText});
and don't forget to add the background page in the manifest
"background_page": "background.html",
voila. text copied to clipboard. would LOVE an easier way to do this (if security is the issue then why not make an api for extensions? or rather, why scrap the experimental api only to force us to do this stupid workaround?) but oh well, this will suffice for the time being

Resources