I'm writing a bit of code to display an EU Cookie notification.
If the visitor does not accept the use of cookies, I want to take them somewhere else. My first thought was to take them to the browser's home page.
I found a way to do it in IE - I have been told that the method on that page is for IE 10 or less.
I have not found a way to do so in other browsers.
If this turns out to be more trouble than it is worth, I'll take them somewhere via a specific URL, such as www.google.com
Does anyone know of the method to accomplish the same thing in browsers such as Firefox, Safari, Chrome, etc?
Most browsers implement an address that will point to the home page. You should be able to redirect the user to the proper location after you figure out their browser.
For Chrome you can link them to about:newtab, which may be different from the home page, but it is probably the closest you will find. The actual homepage button is not implemented in Javascript and does not use a URL.
For Firefox you can link to about:home.
For Opera you can link to opera:speeddial. (I did not test this one, if someone wants to I'll update)
The documentation you linked to claims to be obsolete after IE10. I think you can link to about:home on IE same as Firefox if your solution isn't working afer IE10. (I did not test this one, if someone wants to I'll update).
Related
I have an issue specifying access from SFSafariViewController since it has the exact same user agent as Safari browser.
What i'm trying to do is display a picture only inside the webview and remove it if its viewed on normal browser.
Tried to see if document.refferer can be used and I tried it on twitter since the latest update has its webview changed to SFSafariViewController. Almost worked but the referrer info is also being passed to safari if its opened directly from SFSafariViewController.
Would really appreciate any ideas... thanks!!
I did a bit of quick research on this, and it appears that this is not possible, hence the word Safari in SFSafariViewController.
However you can do this using the WebKit WKWebView: https://developer.apple.com/documentation/webkit/wkwebview/1414950-customuseragent
You can't check the user agent, but there are other detection mechanisms to differentiate sfsafariviewcontroller from safari.
For example, you can check for the existence of an obscure webfont: .Helvetica LT MM.
Here's some example code: https://gist.github.com/aeharding/08eaafbb7742f78ede9b8d2f5d096354
I have input[type=file] with log-in form on it. So after user logged in - file upload dialog instantly opened.
In all browsers I need (FF, IE10+) except Google Chrome, this call works perfect:
$('input[type=file]').click();
or
$('input[type=file]')[0].click();
or
$('input[type=file]').trigger('click');
Did anyone met this problem? If so, how to achieve this on Chrome?
Edit1:
https://developer.mozilla.org/en-US/docs/Web/API/HTMLElement.click here in support it's said that I can use it on input[type=file].
Also this click is working, but only if I'll actually click something, that than is clicking my input(so only after physical click).
Edit2:
And yes, I've already tried search function. But everything I've found was old, and pretty much anyone told, that even FF is not supporting this (which is not true now).
Edit3:
Example test page: http://jsfiddle.net/Ux3t4/
This is not allowed due to security reasons. By the way, even in Internet Explorer (the dialog will be shown but once you select a file, the file won't be submitted).
I've created a website which uses html5, jquery, php, etc. which works fine on Firefox and Google Chrome, but recently I've been experiencing problems with internet explorer 11.
The site first requires you to log in, after which it refreshes the page. The problem in IE11 (and possible earlier versions) is that some dynamic elements (like divs, tables, ...) are not being displayed, while others are.
Now, when I'm on the login page and delete my browser history (only history, not cookies or temporary files or such) and then login, the site works perfect, identical to firefox and google chrome.
Because of this, my guess is this isn't a programming problem, but something to do with loading scripts or such. The strange thing is that some functions do work from some file, yet others don't.
Does somebody know what might be the problem?
"googlechrome://www.lego.com" opened in mobile Safari will switch to Google Chrome iOS app to open the URL. This allows for scriptlets like the one below, which allows you to open the current page in Google Chrome iOS app, switching from mobile Safari:
(function()%7Bif(document.location.href.indexOf('http')===0)document.location.href=document.location.href.replace(/%5Ehttp/,'googlechrome');%7D)();
My question is, can the reverse be done? I tried "safari://www.lego.com", and it is simply an invalid URL. Can you make a scriptlet which switches from Google Chrome to mobile Safari to open the current page.
The answer is yes. Courtesy or MacStories (http://www.macstories.net/tutorials/chrome-for-ios-send-a-webpage-back-to-safari-via-bookmarklet/), I found this code:
window.location='googlechrome-x-callback://x-callback-url/open/?url='+encodeURIComponent(location.href)+'&x-source=Safari&x-success='+encodeURIComponent(location.href);
Execute that code, go to your homescreen, reopen Chrome, and there's a magical back button to go back to Safari. This may not be exactly what you want, but it works... Kink of.
Good luck!
Update:
Here's a screenshot:
Link (Sorry, I don't have enough reputation to put it right in the post): http://i.stack.imgur.com/OR175.jpg
Update:
It seems that the functionality to do this has broken. Thank you!
How do I create a link to set the user's home page to my URL?
As some people have already answered, it used to be possible in internet explorer (prior to IE 7 I believe, could be wrong though) using something similar to
document.setHomePage('www.example.com');
I don't think any browser supports it anymore though. However, I would definitely try to convince you to do otherwise. Most people won't like having their settings automatically changed, even if it's triggered by a mouse click or other action. It's also quite likely that overzealous 'protection' programs will jump all over it and stamp it as a malicious attack.
As far as I know it's just possible in Internet Explorer
Make my Page your
<a href="javascript:history.go(0)" onClick="this.style.behavior='url(#default#homepage)';
this.setHomePage('http://www.test.de');">Startpage</a>.
I assume you mean put a link in your page to make it the browser homepage? In IE you can do something like:
this.setHomePage('http://www.mysite.com');
I don't think that works in Firefox though.