file:// HTML link doesn't open - file

I need to link to a file not served by a webserver, so i'm using this HTML sintax
demo.pdf
Tryed in Chrome, Edge and Firefox: when i click on the link nothing happens. Even right clickeng the link and selecting "Open in a new tab" doesn't work: Firefox and Efge doesn't open the new tab and Chrome opens a new "about:blank" tab.
Here's a fiddle: https://jsfiddle.net/upurrvn0/
What's the matter with this?
#DougDawson already found and ridden that question. I've specified that my files are (unluckly) not served by a webserver. Therefore i need to use a "file:///" link, which i read over several websites should be allowed by browsers. If I manually type the address in the URL bar, i get the file (so the URL is ok). If this has became illegal over the years, I haven't found anything. Can you provide any documentation about it?

Related

React App Favicon Not Showing while sharing website URL/Link [duplicate]

I have a Grails application running locally using its own tomcat and I have just changed the favicon for a new one. Problem is that I can not see it in any browser. The old favicon shows up or I get no favicon at all, but not my new one. I do not think this is a Grails issue per se, more an issue with favicons.
What is supposed to happen with favicons? How are they supposed to work? I have numerous bookmarks in my browser which have the wrong icons and they never seem to get refreshed. How do I force the server/browser to stop caching them? It seems pretty silly to always cache them given they are normally only 16x16. Why not just upload them with every visit to the page? It is not exactly a huge overhead.
To refresh your site's favicon you can force browsers to download a new version using the link tag and a query string on your filename.
This is especially helpful in production environments to make sure your users get the update.
<link rel="icon" href="http://www.yoursite.com/favicon.ico?v=2" />
Adapted from lineofbird's answer beloew, you can do the following:
Go directly to the favicon url in the address bar by typing in it's address e.g.
www.yoursite.com/favicon.ico
www.yoursite.com/apple-touch-icon.png
etc.
Navigate to the url by pressing Enter
Refresh with Ctrl+F5
Restart your browser (e.g. Chrome, Firefox)
This answer has not been given yet so I thought I'd post it. I looked all around the web, and didn't find a good answer for testing favicons in local development.
In current version of chrome (on OSX) if you do the following you will get an instant favicon refresh:
Hover over tab
Right Click
Select reload
Your favicon should now be refreshed
This is the easiest way I've found to refresh the favicon locally.
By destroying the file your browser uses to store old favicons, you can force new ones to be loaded.
Close your browser. Make sure there are no longer browser processes running (e.g. check Task Manager for chrome.exe or firefox.exe).
Navigate to where your browser stores user files:
For Chrome, go to the Chrome data directory.
For Firefox, go to the Firefox profile folder.
Delete the favicon cache.
For Chrome, remove Favicons and Favicons-journal
For Firefox, remove favicons.sqlite
This will almost definitely work. If not:
Possibility 1: An update to your browser has changed how the favicon cache works. Please edit this answer with new instructions.
Possibility 2: Your favicon problem has nothing to do with overaggressive caching. It may instead be a resource-loading problem – using Developer Tools, make sure the new favicon is downloading properly.
Rename the favicon file and add an html header with the new name, such as:
<link rel="SHORTCUT ICON" href="http://www.yoursite.com/favicon2.ico" />
If you use PHP you could also use the MD5-Hash of the favicon as a query-string:
<link rel="shortcut icon" href="favicon.ico?v=<?php echo md5_file('favicon.ico') ?>" />
This way the Favicon will always refresh when it has been changed.
As pointed out in the comments you can also use the last modified date instead of the MD5-Hash to achieve the same thing and save a bit on server performance:
<link rel="shortcut icon" href="favicon.ico?v=<?php echo filemtime('favicon.ico') ?>" />
In Chrome on Mac OS X one can remove file with favicon cache
${user.home}/Library/Application Support/Google/Chrome/Default/Favicons
Depending on the browser they are handled differently, but typically I find that going to the default page of the site, and doing a hard refresh. CTRL + F5 (or ⌘ Command + SHIFT + F5 on macOS), will typically get it to update.
Well, overhead is overhead, but yes, not too big.
Also, browsers are sometimes "greedy" about cached files. You could clear cache and/or restart your browser and may see the change. If that fails though...
My cheapo solution is to:
Visit your file at http://example.com/favicon.ico in your browser.
Delete the favicon.ico from your webroot.
Visit http://example.com/favicon.ico again in a browser, verify it's missing.
Upload new one to your webroot.
Visit http://example.com/favicon.ico again in a browser, verify it's the new one.
If that sequence doesn't work, then something else is going on.
ON MAC:
⌘ + Shift-R or hold down Ctrl and click the reload button in the browser.
For Internet Explorer, there is another solution:
Open internet explorer.
Click menu > tools > internet options.
Click general > temporary internet files > "settings" button.
Click "view files" button.
Find your old favicon.ico file and delete it.
Restart browser(internet explorer).
More than likely a web browser issue. You will have to delete your cache from your browser, close your browser and reopen it. That should fix it.
I don't believe your favicons will get refreshed on your favorites until you revisit that page, and assuming that you had previously cleared your browsers cache.
Your web browser will not go out to the internet to check for a new favicon on its own... thank goodness.
Try Opening In a New Tab
I tried many of the things above (resetting cache, refreshing, using the link tag, etc), I even checked my .htaccess file and reset the ExpiresByType variable.
But this is what finally worked for me in both Chrome (25.0.x) and Safari (6.0.1):
Flushing cache
Hard-linking the favicon with the <link> tag
Navigating to mysite.com/favicon.ico
Opening mysite.com in a new tab
(Up until step 3, refreshing in the same tab kept reproducing the old icon.)
Chrome Version: 68.0.3440.106
Just restart Chrome (in your address bar):
chrome://restart
For Chrome on macOS, if you don't want to delete the entire Chrome favicon database as suggested already here, you can delete only the conflicting icons:
Quit Chrome
Load the favicons database (using sqlite here):
sqlite3 ~/Library/Application\ Support/Google/Chrome/Default/Favicons
Search for the file that is causing issues
select * from favicons where url = 'http://mysite.dev/favicon.ico';
If you are happy with the output:
delete from favicons where url = 'http://mysite.dev/favicon.ico';
Alternatively, you can search for a pattern that you can reuse to delete multiple entries:
Search for multiple files that are causing issues
select * from favicons where url like 'http://mysite.dev%';
And again if you are happy with what this returns:
delete from favicons where url like 'http://mysite.dev%';
Type .exit and hit return to quit sqlite
Restart Chrome
When you request the favicon from Google, you can take a look at the response headers.
Last-Modified: Fri, 09 Jan 2009 16:35:02 GMT
Date: Thu, 01 Dec 2010 00:00:01 GMT
Expires: Fri, 01 Dec 2011 00:00:01 GMT
Cache-Control: public, max-age=31536000
Age: 7
If you put an "Expires: " header on the response, client browsers will re-request the icon after that timestamp. While doing active development, you could set the expires timestamp to a second or two in the future, and always have it fetch this, although that's a poor longterm plan.
Chrome's favicon support is buggy - disregard this answer
I wrote this answer under the impression that this is what it took to refresh favicons in Google Chrome. However, it turns out that this only works for the first five minutes or so, until the icon gets irretrievably lost in Chrome's history synchronization.
Original answer
You don't have to clear your cache, restart your browser, or rewrite your HTML - you just need to change the icon's URL, once, so that the browser will forget the previously-cached icon.
Assuming that you've defined your icon via <link> elements in your page's <head>, you can do that by running this standard-JS one-liner in the console:
[].slice.call(document.querySelectorAll('head>link[rel$="icon"]')).map(function(ln){ln.href+='?v=2'});
For a more advanced implementation of this that can automatically do this for end users in production, see freshicon.js.
I recently restored my bookmarks and was looking for a way to restore the FavIcons without visiting each page. My search brought me to this thread.
For those in a similar circumstance merely download the FAVICON RELOADER addon. Once installed you will find the "reload favorite icons" command in your BOOKMARKS dropdown menu.
https://addons.mozilla.org/en-US/firefox/addon/faviconreloader/?src=api
If you are using PHP .. then you can also use this line.
<link rel="shortcut icon" href="http://www.yoursite.com/favicon.ico?v=<?php echo time() ?>" />
It will refresh your favicon on each page load.
If you are just interested in debugging it to make sure it has changed, you can just add a dummy entry to your /etc/hosts file and hit the new URL. That favicon wouldnt be cached already and you can make sure you new one is working.
Short of changing the name of the favicon, there is no way you can force your users to get a new copy
This is a workaround for the chrome bug: change the rel attribute to stylesheet! Keep the original link though. Works like a charm:
I came up with this workaround because we also have a requirement to be able to update customer's sites / production code and I didn't find any of the other solutions to work.
This works for Chrome:
on Mac: delete file
${user.home}/Library/Application Support/Google/Chrome/Default/Favicons
on Windows: delete files
C:\Users[username]\AppData\Local\Google\Chrome\User Data\Default\Favicons
C:\Users[username]\AppData\Local\Google\Chrome\User Data\Default\Favicons-journal
source
I know this is a really old question but it is also one that is still relevant, though these days applies only to mozilla. (I have no idea what explorer does coz we don't code for non standard browsers).
Chrome is well behaved if one includes an icon tag in the header.
Although mozilla are well aware of the issue, as usual, they never fix the annoying small stuff. Even 6 years later.
So, there are two ways of forcing an icon refresh with firefox.
Have all your clients uninstall firefox. Then re-install.
Manually type just the domain in the url bar - do not use http or www
just the domain (mydomain.com).
This assumes of course that your ns records include resolution for the domain name only.
Simple,
1: I don't want to fiddle around with codes (ps my site builder doesn't use codes, it uses "upload file" button and it does it itself)
2: I tried the CTRL+F5 and it doesn't work for me so....
I HAVE A SOLUTION:
IE: Clear All browser history and cookies by going to the settings cog O
Chrome: Go to the menu in the top right corner below the X that looks like a = , then go to settings, history, CLEAR BROWSING DATA and check all of the boxes that apply (I did history, cookies and empty the catche from the beginning of time)
Just change this filename='favicon1.ico'
Here's how I managed it with a simply animated favicon and FireFox 3.6.13 (beta version) It will probably work for other versions of FireFox as well, let me know if it doesn't.
It's basically artlung's solution, but addressing the .gif file as well:
I opened by FTP program, downloaded my favicon.ico AND favicon.gif files,
then DELETED them from my server's files.
Then I opened them in my browser as artlung suggested:
http://mysite.com/favicon.ico AND http://mysite.com/favicon.gif Once those addresses loaded and displayed 404 error pages ("page not found")
I THEN uploaded both files back onto my server, and PRESTO - the correct icons were instantly displayed.
Also make sure you put the full image URL not just its relative path:
http://www.example.com/images/favicon.ico
And not:
images/favicon.ico
Use query string at the end of the file path. Query string variable value must be different with every build.
if previous build is:
<link rel="icon" href="http://example.com/favicon.ico?v=v1" />
OR
<link rel="icon" href="http://example.com/favicon.ico?v=stringA" />
then next build should be:
<link rel="icon" href="http://example.com/favicon.ico?v=v2" />
OR
<link rel="icon" href="http://example.com/favicon.ico?v=stringB" />
Close all Google Chrome windows
Adding one more answer that I do not see here. I tried flushing my Google Chrome cache, reloading the tab, refreshing the tab, opening in a new tab, and even opening a new window. Nothing worked for me. What did finally work for me was to close all Google Chrome windows (if you're like me, you probably have 3+ windows with a bunch of tabs, and maybe even have more windows/tabs in another desktop, don't forget those!). Once all of your windows are closed, then try opening a fresh new window and reloading your site.
Hope this helps someone!
Bonus tip: If you'd like to get all your windows back, you can press "Ctrl + Shift + Up Arrow + T" to get your windows and tabs back.
If the problem continues despite of applying some steps above:
try to restart the IIS Server.

How to know which element receives the click()?

I am writing a script that goes to an Amazon URL and clicks on the 'Buy Now' button. That's it. I have to use WebdriverIO, javascript, and ChromeDriver. The problem is that I can't get this button to be clicked no matter which selector I use. I am able to manually do it just fine. But in the Code Inspect below, every combination of div/id/name, span/id/close, or input/id/name has resulted in no clicks. I know the script can see that web object because when I do a BuyNow.getText() to console, it prints out 'Buy Now'. And I know the xpath I use is good because I paste it into Inspect/Find and the exact element lights up yellow. Oh and the .click(), even though Visual Studio Code flags as deprecated, works just fine in previous scripts.
When I manually click on a button, is there a way to see what was the exact element that received this click?
let BuyNow = $(<XPATH>)
BuyNow.click()
Code Inspect
Ok so I found out what the problem was. It had nothing to do with my XPATH selectors, any one of which to the elements in the Code Inspect picture would have worked (example: let BuyNow = *[id='buy-now-button']). The issue is that in the WDIO config file, I had a custom Chrome Profile being used. Which is fine, the Chrome.exe I was using was pointing to another custom Chrome Profile. I thought these two were the same, but the folders paths were getting messed up. Once I resolved them, and had both the Chrome.Exe and WDIO config pointing to the same customer folder, Chrome started to allow me to select buttons. I think that the WDIO code was looking at one user profile of chrome, and the desktop chrome browser that I was using was another user profile.
Solved. Fun Stuff but not really.

Get destination of silverlight link

I visited a web page with an embedded silverlight.
If I press a specific button on that page, I will get a download window in Firefox. So I think this is just a link. Can you tell me how I can get the HTTP address of the link?
I want to create an http link to the same destination but for this, I need the destination..
Best,
dwi
I got it. Just download in Firefox and go to download history.
There you can right click and select "Copy download link".

Selenium: close tab when image: Message: Unable to locate element: {"method":"tag name","selector":"body"}

I'm using python and selenium with firefox. To reach the pages, I must authenticate, and there are redirects involved to login and following the login (I have that working properly, thankfully). Now I need to save images on these SSL-based pages, so currently I open images (e.g., something.jpg or something.svg) in new tabs and take screenshots, as suggested elsewhere on stackoverflow. However, when Firefox loads an image in a tab, such as .SVG, there is no "body" element to find and thus I get an error (Message: Unable to locate element: {"method":"tag name","selector":"body"}) when trying
body = driver.find_element_by_tag_name("body")
Question: How can I close these image tabs?
It turns out that I should not be using tabs, since Selenium support for them is limited. Instead, I should use Selenium's window handler to open and close different URLs. That worked far more reliably, especially as follows:
# open current window
driver.switch_to_window(driver.window_handles[0])
# open last window
driver.switch_to_window(driver.window_handles[-1])

mailto: links gobbled in a route

I'm using the jquery linkify plugin on a relatively simple Backbone view. Links to web pages outside this app work properly and using browser view source, I see the mailto links are properly generated. But clicking a mailto link appends /mailto:q#example.com to the current URL (e.g., http://example-acme.staging.myservername.com/mailto:q#example.com).
If I copy the generated HTML using Inspector and paste it into the source of arbitrary pages (not in this app), the mailto links function as expected, opening a new message window from my mail client. Problem is the same in Chrome and Firefox.
Have you seen and fixed this issue?
Just for closure: I added an event handler in the handler use window.location.assign(mailto) and that gets the job done. Not necessarily 'correct' but practical. #Brad, thanks for chiming in!

Resources