Browser detection problems - mozilla

I have a website that will be displayed in all browser but I need it to display an alert box on load only in Firefox.
How can I detect the browser and specify that if it is mozilla the alert should pop up?

You could include jQuery in your website and try the following code:
if ($.browser.mozilla) {
alert( "this is mozilla!" ); // popup if the browser is mozilla
}
PS: Bear in mind that all Mozilla derivates are recognised here.

Related

Chrome.windows.onCreated in background script wont recognize browsers first opening

I need to call some method on opening browser from background page in my chrome extension. It works for me on my pc and chrome, but on some other pc's and same version chrome not working. Working only if second browser is opened. Somehow that chrome's api dont see first browser is opened.
Chrome version latest (75.0.3770.90)
chrome.windows.onCreated.addListener((window) => {
this.doSomething(window);
});
function doSomething(window) {
console.log('Window with id: ', window.id, 'opened');
}
I expect to console log every windowId which is opened, but i get only from second opened window.

WebView, opening link in different window/tab

Is it possible to open a link like this to be opened in Safari by only changing the contents of the HTML file only?
My WebView loads a local HTML page with this source:
Link to Fanpage
How do I make it so that it opens in Safari? By default it should also open in Facebook app if it was downloaded?
It's annoying that it opens the Facebook page on the same webview and the user won't be able to go back to the previous webpage.
Would I have to face a new approach? Thank you.
I looked at other solutions but I don't know what it means by adding a delegate to the webview?
I think you are trying to get get back-history working with anchors on iOS? I have been dealing with the same issue.
Thanks to inspiration from http://www.bennadel.com/, created the following angular directive that fixes this back-history issue. Basically it overrides the default html anchor behavior.
.directive('anchorOpenInNewWin',function() {
return {
restrict : 'A',
link : function($scope,$element,$attrs) {
$element.bind('click touchstart',function(e) {
e.preventDefault();
e.stopPropagation();
location.href = $attrs.href;
});
}
}
});
<a anchor-open-in-new-win href="http://www.google.com" target="_blank">google</a>
This solution could be easily translated into jquery or whatever you are using. Hope this helps

How to view cookies set by google chrome extension?

I'm working on a google chrome extension which has a button and a popup-overlay. Inside this extension, I set and remove cookies for the user. During development, the extension is making requests to localhost:8080 and (I assume) cookies are being set with localhost as the domain.
The problem is, I can't figure out how to view these cookies in a list from within Chrome. Firefox has a simple feature for viewing all the cookies set by various hostnames and Chrome appears to as well (although I'm less familiar with the developer tools in Chrome). But in Chrome's cookie list, I can't find any cookies set for localhost, nor any cookies for my extension, whatsoever. I've tried a few 3rd party cookie extensions too -- no luck there either.
Will cookies set by extensions appear in the same place as cookies set by normal websites? If so, why am I not seeing them? Help appreciated. Thanks!
Yes they appear in sample place.. I have written a sample extension for demonstration; Screen shot taken after testing this for developer.chrome.com domain
Sample Extension:
manifest.json
{
"name" : "Cookie API Demo",
"version" : "1",
"description" : "This is demonstration of Cookie API",
"permissions": [ "cookies","<all_urls>"],
"browser_action": {
"default_icon": "screen.png",
"default_popup":"popup.html"
},
"manifest_version": 2
}
popup.html
<html>
<head>
<script src="popup.js"></script>
</head>
<body>
</body>
</html>
popup.js
function cookieinfo(){
chrome.cookies.getAll({},function (cookie){
console.log(cookie.length);
for(i=0;i<cookie.length;i++){
console.log(JSON.stringify(cookie[i]));
}
});
chrome.cookies.getAllCookieStores(function (cookiestores){
for(i=0;i<cookiestores.length;i++){
console.log(JSON.stringify(cookiestores[i]));
}
});
chrome.cookies.set({"name":"Sample1","url":"http://developer.chrome.com/extensions/cookies.html","value":"Dummy Data"},function (cookie){
console.log(JSON.stringify(cookie));
console.log(chrome.extension.lastError);
console.log(chrome.runtime.lastError);
});
chrome.cookies.onChanged.addListener(function (changeInfo){
console.log(JSON.stringify(changeInfo));
});
}
window.onload=cookieinfo;
Well I figured it out. It's a forehead slapper, but I'll post the answer here anyway in case others need help.
The cookies for the overlay extension only show up in the "developer tools" if you inspect the overlay element. That is, if you close the overlay and click the wrench button, developer tools, resources, cookies, the only thing you'll see there are cookies for the underlying page.
In order to see cookies for an overlay extension, right-click INSIDE the overlay and "inspect element". The cookies do show up there, and the "domain" they're attached to is the extension's unique id (kackjckjckjckcjckjckcjkcjckcj or what-have-you).
Random note: At the time of this writing, the Jquery cookies plugin always kills your cookies at session, no matter what you set the expiration to. In order to get my cookies to persist (survive) beyond browser close, I had to include good old-fashioned setCookie() and getCookie() functions and get rid of Jquery cookies.
In your browser - visit:
chrome://settings/cookies
I just set it as the address for a bookmark in chrome - and then just click my bookmark when I want to see the cookies

mailto links not working in Chrome and Safari Mobile

In my jQuery Mobile App, I have a mailto link, its href attribute is dynamically generated and it is 'clicked' via jQuery.Here is the link code:
<a id="mealLink" href="mailto:123#123.com" style="display: none;">This is the mailto
link</a>
A click handler is attached to it like this:
$('#mailLink').bind('click', function() {
window.location.href = $(this).attr('href');
});
Lastly,a function creates the href attribute for the link with emailaddress, subject and message body and click is simulated via jQuery:
$emailAddress= ..
$subject= ....
$body=...
$emailString="mailto:"+$emailAddress+$subject+$body;
$emailLink= $("#mealMail");
$emailLink.attr("href",$emailString);
$emailLink.click();
Now, this code is working perfectly in:
Mozilla desktop
Safari desktop
Android
But not working in:
Safari Mobile
Chrome desktop
Any suggestions?
After searching for complex solutions, I found a much easier solution by chance. The issue here is that if a mailto link is directly clicked, it works in all browsers, but if it is indirectly clicked, such as via jQuery .click() function, it does not work in all browsers. Therefore, here is my implementation:
This is a mail to link
$emailAddress= ..
$subject= ....
$body=...
$emailString="mailto:"+$emailAddress+$subject+$body;
$emailLink= $("#emailLink");
$emailLink.attr("href",$emailString);
Now, depending upon the context of an application, the href parameter of the link can be setup and when this link is clicked, it works. I have tested in following browers:
Mozilla Firefox Desktop
Safari Desktop
Chrome Desktop
Safari mobile on ipad 1
You should not use mailto:
Check if is not better to create a simple "Contact us" form.
But still, take a look at this: i-cant-get-mailto-links-to-open-the-mail-app-from-mobile-safari-when-using-jqto

sencha touch :: is it possible (and how) to open a website inside a panel or in external browser window?

i wonder if and how it is possible to open a website inside a panel or in an external browser window of the mobile safari! I tried to open a website inside a panel but due to crossdomain problems only the htm without the css was loaded.
any ideas?
thnx!
edit: let's say, we use phoneGap
As far as I know, cross-domain issues do block you from IFRAME solutions for displaying external links inside your app.
Best solution currently is to have links include target="_blank" to force a new browser window to open.
#Stevanicus #Dalar It does open a new window in Mobile Safari if you use Phonegap and allowed domains using phonegap.plist whitelist property, but if you do somthing like
var rateMsg = Ext.Msg.confirm('Title', 'Some message', function(e) {
if(e == 'yes')//If user confirms yes
{
window.open("http://www.example.com", "_blank");//We open a link with _blank to use mobile safari and not your webview
}
});
It does not work.

Resources