make webpage recognize my own device for debug purpose through javascript - javascript

I build my site with Joomla, by default the page is responsive. I want to turn off responsive design, but there is no turning off option on back-end, so I had to use:
$('meta[name=viewport]').attr('content','width=1200px');
to turn off responsive so that I didn't have to bother with mobile layout .... for a while. Now the site is live, and I am about to start to make the page responsive. I want to debug this on the live page but don't want other users to see some messed up page when I am still tweaking it. So I am thinking whether there is a way to make the page recognize my own devices only.
I understand that I can use login system, but that would be too complicated. The simplest way I can think of is to do this
if (location.search.indexOf('nores') < 0) {
j('meta[name=viewport]').attr('content','width=1200px');
}
and then open each page like this mystie.com?nores. But this is still a little troublesome, besides I can't freely navigate pages.
The other way I was able to find out is to add some custom string to userAgent, I think this can be done through chrome's developer tools, but what about mobile browser? Similar is using localStorage, on PC, I can just open the page, go to console and do localStorage.setItem('nores',true), but how can I do this for my phone?

Related

Force Open External Browsers instead of any in-app browser [HTML/Javascript]

I've already researched and found a lot on this topic, but there's an idea that I still couldn't find and wanted to see if it's possible.
A bit of a background, I'm not a back-end developer and I'm not as well versed in it. But I have written a small website using HTML, CSS & Javascript (jQuery).
In-app browser is a problem for me since I am using localStorage to store some information for the user, and being its in-app then the user will lose all those details once they leave instagram, for example.
I've come upon a few results, and some here on stackoverflow, but some answers did not work (link 1, link 2) and most answers said that this is not possible anyway.
So I was wondering (and I'd take this as a learning experience) about the following use case:
Let's take Instagram as the example here. If we set in our bio the link to youtube let's say, the youtube website will display at the top "Open in App" button, which in that way can then open the native youtube app and the user can continue normally. In that sense, isn't it possible to let's say, to create a button like "Open in Safari", and once the user opens my website they will be able to tap it and it would open the safari app with its appropriate link? Or is this not possible also since it should be coded from Safari's end?
A URL Scheme is what you need. for example:
Google Chrome:
googlechrome://domain
Safari:
safari-https://domain
Firefox:
firefox://open-url?url=domain
Opera:
opera-https://domain
X Web:
x-web-search://search+term

Webpage input element, not URL / Open Site Dialog

I am working on an application that asks individuals to paste links to their social media and other relevant sites as part of the setup process. These later get turned into links on a compiled HTML page.
We are seeing a user issue that is arduous to deal with. When setting up the account on mobile, individuals do not understand that they need the website link to these various places, they try and open the target sites app instead (Facebook as an example), or they stare blankly unsure of what to put in the box or how to proceed.
I'm looking for a solution to this conundrum to help people achieve their ultimate end goal of putting the link on the resultant page.
I tried an iframe approach, whereby the thought was to load the target site, allow the user to navigate to the desired page, and hit a done button. Obviously this approach ran into several road blocks due to security restrictions and frame busting implemented by the various sites.
What would be great would be something like the file input, but for websites instead. We have the "URL" input; however, that only checks the URL for validity, I'm more interested in an approach that would open something akin to the file dialog, that would allow a user to navigate to a site and hit "done"
I've not been able to find anything that comes close. I'm seeing if someone knows something I do not, or has an idea I haven't yet tried. Ultimately, I'm trying to make it easy for an average consumer to choose the target for a link. (I'm fully aware how easy it is to open a browser tab and copy the link, I am truly supporting consumers who find that somewhat difficult / confusing)
Thank you for your time and consideration

From website to app to website on iOS

I'm working on an iOS app some people want to link to from their website.
While I've managed to open my app from a webpage using schemes, I wonder if, when I'm done with what I have to do in my app, I can switch back to the original website tab in safari.
To my knowledge : it is pretty straightforward to open a new page in safari from my app but I don't know if it is possible to get back to the actual original page, just like the ios9 back-to-app button would do.
I could open a new page and close it straight away with some javascript, which would probably display the original page because it's the next one in the tab list... but it doesn't feel right (does it?)
I read stuff about ios9 deep linking, still can't find anything interesting.
To achieve this is to open Safari using URLScheme. However, (afaik) Safari App doesn't have a url scheme. If the user came to your app from Chrome, than you can use its url scheme
Google Chrome has the following two URI schemes: googlechrome:// and googlechromes://
iOS 9's back to app button can't be invoked programmatically, so you can't use it as well. However in jailbreaked devices an app can mimic that, maybe that will help you http://theunlockr.com/2015/08/23/enable-back-button-ios-8-video/
I could open a new page and close it straight away with some
javascript, which would probably display the original page because
it's the next one in the tab list... but it doesn't feel right (does
it?)
It doesn't feel right at all. Because the typical behaviour for turning back to previos (or any other) application among iOS users is pressing home button twice, and selecting the app. Maybe you can simply show a message, and ask user to return Safari.

How to ink to another .html page within Chrome extension/app?

I am building a chrome app for a client that will run in kiosk mode to display in their stores. Right now I have an index.html page that links to about 30 other pages. However, when I click on a link in the app I get an error...
Can't open same-window link to "chrome-extension://leghflngpfmomcflabikghiemaajadne/poweredge"; try target="_blank".
So I tried target="_blank" and that tries to open it in a new chrome window.. no good. I've been reading a little bit about using webview and sandboxing pages but they both open the pages in a new window and it just doesn't look good.
Is there a better way to do this? Right now my only idea is to place all of the content on the index.html page and turn on/off sections of the content with jQuery. I'd love to keep all of the pages separate though, just for my own sanity.
Thanks!
Navigation is disabled for the Chrome Apps platform. In theory you are supposed to make single-page apps - so your turn on/off approach is the "intended" one.
No-one stops you from having several windows though - suppose you have an options page, it wouldn't be strange to open it separately (via chrome.app.window.create)
As stdob mentions in comments, a workaround may be possible by using <webview> with a partition blessed to show local resources. It's not clear though if it will allow access to apps APIs.

Linking between pages and loading JavaScript using jQuery Mobile

I'm working on my first jQuery Mobile site, which is a (prototype for) a Location Based Game in Brisbane, Australia: www.jsjensen.dk/soleil/
My question is based on viewing from a mobile device, but a desktop device have very similar problems. I have tested with Chrome and Safari on iPhone, iPad, and Mac. Same problem everywhere.
I think it's related to how jQuery Mobile loads and displays pages, but I'm not using multiple pages in one HTML document, but have multiple HTML document.
If you go to the website above and then click "QUESTS" in the menu, followed by "Stairway to Knowledge" you will end on /soleil/quest01.html (desktop) and /soleil/#/soleil/quest01.html. That "#/soleil" really confuses me!
In this first try the JavaScript for handling answers in the text input is not loaded. That means nothing happens when you press "Unlock".
Now, if you reload on desktop or edit the address on iOS to /soleil/quest01.html (which is the actual and real file) it will reload the page with the right JavaScript loaded and initialized.
Now I'm able to go back (pressing "QUESTS" in the menu) and then go to another page (e.g. "Citadel of Fun") with the same problem: the JavaScript not loading. If I go back to the other one ("Stairway to Knowledge") the JavaScript is, however, still loaded and working just fine.
So what happens here? I'm pretty sure my linking/coding is correct, but it's just a basic understanding of jQuery Mobile that I'm missing. Can I change something to make this work? It could really be awesome!
So, I found a way to fix it, but not really a solution to the original problem.
I've added rel="external" to the tags pointing to the pages where I had problems. In this way it will not use the AJAX system to load these pages, but do it in a regular way. This solved my problem, but now I can't make any fancy transitions.

Categories

Resources